I\'m running code on a microcontroller with .NET Micro Framework, and I want my debug output to write to a text file. How does this work?
Ekk is right about Trace being a better design, however that doesn't answer the question, which would be fine in the absence of a direct solution. The OP or someone may have inherited a code base which uses Debug throughout, and Trace may not be desirable at the time.
I found this solution http://bytes.com/topic/c-sharp/answers/273066-redirect-output-debug-writeline:
TextWriterTraceListener[] listeners = new TextWriterTraceListener[] {
new TextWriterTraceListener("C:\\debug.txt"),
new TextWriterTraceListener(Console.Out)
};
Debug.Listeners.AddRange(listeners);
Debug.WriteLine("Some Value", "Some Category");
Debug.WriteLine("Some Other Value");