Using the return character "\n" or "\r", and saving it to a text file, when opened in notepad, the return does not show, but it shows in rich text editors. Is there a return character in .net that works in notepad
For some weird reason, you're right, \n is not properly saved on a TextFile. The way I save multi-lines of text is I split the string into lines, using \n as my delimiter:
string test = "Test\nTest in line2"; string [] lines = test.Split('\n');
And then, if I work on a TextWriter, I usually iterate through the lines of strings, and use the WriteLine() method instead of Write(), here's a code to show my method:
string test = "Test\nTest in line2"; string [] lines = test.Split('\n');
TextWriter tw = new StreamWriter(@"c:/test.txt");
foreach(string line in lines) { tw.WriteLine(line); }
tw.Close();
// To display it on a multi-line TextBox: textBox1.Lines = lines;
Maybe other people here can give us a better approach.
Plain Text Return
Venom
For some weird reason, you're right, \n is not properly saved on a TextFile. The way I save multi-lines of text is I split the string into lines, using \n as my delimiter:
string test = "Test\nTest in line2";
string [] lines = test.Split('\n');
And then, if I work on a TextWriter, I usually iterate through the lines of strings, and use the WriteLine() method instead of Write(), here's a code to show my method:
string test = "Test\nTest in line2";
string [] lines = test.Split('\n');
TextWriter tw = new StreamWriter(@"c:/test.txt");
foreach(string line in lines)
{
tw.WriteLine(line);
}
tw.Close();
// To display it on a multi-line TextBox:
textBox1.Lines = lines;
Maybe other people here can give us a better approach.
-chris
aabes
Game Lover Jon
Thanks
-Kyro