Can I write line of text into file and see changes after each call WriteLine
? Now I see changes in this file only after closing StreamWriter
.
StreamWriter sw = new StreamWriter(string path);
sw.WriteLine("text");
in this place I want to preview my file
sw.Close();
now I see writed line only in this moment
Output to the StreamWriter
is buffered by default.
Try this:
sw.AutoFlush = true;
See here http://msdn.microsoft.com/en-us/library/system.io.streamwriter.autoflush.aspx