Hello!
I noticed a strange problem. The below code whould write 4 lines in a notepad file.
When I manually open the testfile.txt
in the notepad application, it looks like it is 4 lines. But when looking in notepad, all those 4 lines exists on 1 line in notepad which is strange.
I notice that it is because of the last line I write in the file which is a very long string as can be seen below. If removing the last line in this code, then 3 lines will be seen in the notepad application.
I don't understand why the last line which is very long makes everything exists on 1 line?
I have those long strings and need each string to be appended on a new line in notepad.
What am I doing wrong? /Thank you
StreamWriter writer = null; FileStream fs = null;
fs = new FileStream("C:/folder1/testfile.txt", FileMode.Create, FileAccess.Write, FileShare.ReadWrite); writer = new StreamWriter(fs);
writer.WriteLine("ooo");
writer.WriteLine("ooo");
writer.WriteLine("ooo");
writer.WriteLine("ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
writer.Close(); fs.Close();