According to http://www.15seconds.com/issue/020910.htm I am doing this
in the c'tor of a 'logfile' class:
objStream = new System.IO.FileStream(logFilename,
System.IO.FileMode.OpenOrCreate);
objTraceListener = new TextWriterTraceListener(objStream);
Trace.Listeners.Add(objTraceListener);
So, now all Debug.Write and Trace.Write get logged to the file. In
the d'tor I am doing:
Trace.Flush();
Trace.Listeners.Remove(objTraceListener);
objStream.Close();
(I added the Trace.Listeners.Remove part myself, since the tutorial
didn't mention it. Without Trace.Listeners.Remove, any calls to
Debug.Write will fail in the tutorial after the the stream is closed.)
But, in the d'tor, if I call Debug.Write or Trace.Write *before* the
above, it'll complain that I am writing to a closed file. It makes no
sense. If I run the debugger and step through it, it doesn't
complain, just as it shouldn't.
When / how do I close the file?
Zytan