Click here to Skip to main content
15,899,026 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi All,

The caffine powered project is now nearing sign off so I was checking some thing
and looked in a save file and found the data all on one line, almost like it is not splitting the input correctly how ever the unit returns the data all on one line,
despite having \n put in however if I use a message box to display the string I wish to write to the file " Unit_Reply_Modded " all the data appear correctly spaced so I write it with
C#
sw.WriteLine(Unit_Reply_Modded);

It all appears on the one line. I have been testing this on XP the only thing that has changed is I am now using Win7 (the XP machine died), as the data is correctly formatted in the text box I am thinking if I read the string into a foreach loop and write it out with a \r\n. opions on this please (there goes my lunch hour again!)

Glenn
Posted
Updated 25-Oct-12 1:14am
v2
Comments
Ambesha 25-Oct-12 7:18am    
will you share your code please, for better analysis :)
glennPattonWork3 25-Oct-12 7:24am    
Thanks, I have it working now the foreach solved it. I have got to get better at asking questions!

Hi All,

Heres the solution I was away from my desk (something else "MORE" important took priority) Looks I am going to be building installers at home!!
Heres What solved the problem I did think of this as I was typing the question
C#
foreach (string subString in Unit_Reply_Modded.Split('\n'))
{
    //MessageBox.Show(subString);
    sw.WriteLine(subString);
}

I do that more often than I would like to admit.
Glenn
 
Share this answer
 
if your are writing to a new file or owerwriting to existing file
use
C#
sw.Write(Unit_Reply_Modded);

insteed of
C#
sw.WriteLine(Unit_Reply_Modded);

this will help you
or at the time of reading to each line with split
C#
yourTextControl.Text.Split(new char[] { '\r' });
 
Share this answer
 
Comments
glennPattonWork3 25-Oct-12 7:34am    
Thanks, got it my self

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900