Normalize line endings, how?
I'm working with Visual studio, I'm writing to a file, when I open the file in Visual Studio's text editor I get the following error:
"The line endings in the following file are not consistent. Do you want to normalize the line endings?"
How can I normalize the line endings from code before displaying the file?
Visual Studios error prompts you to normalize, I've compared a normalized and un-normalized file, the only difference I see is the File Type is different in the files properties, the normalized files type is "PC" the un-normalized in "Unknown", is this a clue?
Re: Normalize line endings, how?
It seems like when you write your file you sometimes use PC end-of-line CR/LF and sometimes unix end-of-line that is only a LF.
Edit: Should have mentioned. The proper way to add a newline character is by using Environment.NewLine. I.e. String myStr = "Some text" + Environment.NewLine;
Re: Normalize line endings, how?
SMA,
You are bang on, I just came across it in the msdn docs and then tried it before you're response and it'sexactly what the problem was.
Environment.NewLine instead of \n is the solution. :)
Lovely jubely.
Re: Normalize line endings, how?
Re: Normalize line endings, how?
Hi Guys,
I have the same problem but not sure what you mean by Environment.NewLine???? Where do I do this and how?
Many thanks
Re: Normalize line endings, how?
Quote:
Originally Posted by
S_M_A
Edit: Should have mentioned. The proper way to add a newline character is by using Environment.NewLine. I.e. String myStr = "Some text" + Environment.NewLine;
Of course if you are using a "WriteLine" method, then this is done implicitly, and you do NOT add a newline (in any form) to the data itself....
Re: Normalize line endings, how?
Quote:
Originally Posted by
Mona777
Hi Guys,
I have the same problem but not sure what you mean by Environment.NewLine???? Where do I do this and how?
Many thanks
http://msdn.microsoft.com/en-us/libr...t.newline.aspx