0

Currently, I have a method that is called when there is an unhandled exception. All this does is log the exception to a dump file. However, the streamwriter does not write the full information I'd like it to write to the file. I assume this is because the program has shutdown before it can finish writing the file.

Is there any way to change this behaviour?

It'sNotALie.
  • 22,289
  • 12
  • 68
  • 103

2 Answers2

2

Call Flush on the stream writer

Ankur
  • 33,367
  • 2
  • 46
  • 72
2

use

using(var stream = new StreamWriter(@"C:\..."))
{
    //logic
}

This will make sure, that stream will be closed and flushed in the finally section.

Ilya Ivanov
  • 23,148
  • 4
  • 64
  • 90