I want to keep a logfile, and I am using TextWriter/StreamWriter to write messages to my logfile. I call TextWriter.Flush() after writing the message, but my message still doesn’t show up right away. It only shows up when I call Close, and I would rather not reopen and close the file all of the time just to see messages immediately.
I want to keep a logfile, and I am using TextWriter/StreamWriter to write messages
Share
You might want to try constructing a FileStream yourself passing in the FileOptions.WriteThrough to the constructor. Then construct your StreamWriter with that FileStream. The WriteThrough option bypasses the cache.