Writing debug output to a .txt file in C#
c#
Solution
Use `Trace.WriteLine("text")`. It's designed exactly for what you are trying to achieve.
Problem
I'm running code and I want my debug output to write to a text file. How does this work? I tried to write: ``` TextWriterTraceListener[] listeners = new TextWriterTraceListener[] { new TextWriterTraceListener("W:\\C.txt"), new TextWriterTraceListener(Console.Out)}; Debug.Listeners.AddRange(listeners); Debug.WriteLine("Some Value", "Some Category"); ``` But it still writes to the output window... What should I do?