|
-
June 1st, 2007, 03:26 AM
#1
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?
-
June 1st, 2007, 03:33 AM
#2
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;
Last edited by S_M_A; June 1st, 2007 at 03:38 AM.
-
June 1st, 2007, 03:53 AM
#3
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.
-
June 1st, 2007, 04:00 AM
#4
Re: Normalize line endings, how?
Nice to hear!
-
January 13th, 2009, 09:03 AM
#5
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
-
January 13th, 2009, 09:05 AM
#6
Re: Normalize line endings, how?
 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....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
January 13th, 2009, 09:17 AM
#7
Re: Normalize line endings, how?
 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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|