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 am wondering that when I open a file in notepad. I see a
I have a file that I open and parse and some of the categories
I have open pdf file through my application.when click on device back button it
Suppose I have a source file that is 18218 bytes. I open the file
I'm writing a C# app to read a file that another application holds open.
I have a PCL file and open it with Notepad ++ to view the
I have an application (winforms) that downloads a file to user's temporary folder, then
I have some code that is reading a config file, but when I open
I have a TXT file that i need to import via an application, but
Suppose I have a source file open and I launch a shell. I can

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.