Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 157809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:34:12+00:00 2026-05-11T10:34:12+00:00

I have a file. When I open it in Notepad I see charachters in

  • 0

I have a file. When I open it in Notepad I see charachters in a single line. However, if I open that file in any other application like WordPad or Notepad++. I can see irregular line breaks between charachters and they appear in multiple lines. These line breaks also appears if I do reader.Readline(). How can I perform Notepad like line read in C#?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:34:13+00:00Added an answer on May 11, 2026 at 10:34 am

    Sorry for second answer from me, but I just realised that you could use peek to get next character and check if current and next are \r\n, like so:

    var path = 'c:/test.txt';  File.WriteAllText(path, 'a\nb\r\nc');  using (var stream = File.OpenRead(path)) using (var reader = new StreamReader(stream, Encoding.ASCII)) {     var lineBuilder = new StringBuilder();     string line;     char currentChar;     int nextChar;     while (!reader.EndOfStream)     {         currentChar = (char)reader.Read();         nextChar = reader.Peek();          if (!(currentChar == '\r' && nextChar == '\n'))         {             lineBuilder.Append(currentChar);         }          if((currentChar == '\r' && nextChar == '\n') || nextChar == -1)         {             line = lineBuilder.ToString();             Console.WriteLine(line);              lineBuilder = new StringBuilder();              reader.Read();         }     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML file, which I open in F# like this: let Bookmarks(xmlFile:string)
Suppose I have an open file. How can I detect when the file is
I have: <?php $file=fopen(date(Y-m-d)..txt,r+) or exit(Unable to open file!); if ($_POST[lastname] <> ) {
In php I have open a .php file and want to evaluate certain lines.
I have a FAT12 image file and I have to open it and read
I want to open a save file dialog, have the user enter a filename,
In the filesystem I have /file.aspx /directory/default.aspx I want to configure IIS so that
I have a file that I want to include in Python but the included
I have a file in the following format: Data Data Data [Start] Data I
I have Windows File sharing enabled on an OS X 10.4 computer. It's accessible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.