I have built a library that dumps most of its debug text using Console.WriteLine();
I am now I am the process of using the library in a Windows Forms Application, and s
Rather than try to "capture" text sent to the console, I would create a new class that handles writing the output for you. Then that new class could write to the console, as well as anyplace else you want it to go.
If you're using .NET's Debug class, simply use two listeners: a ConsoleTraceListener and a TextWriterTraceListener.
To make your existing code work, add:
writer.Flush();
after your Console.WriteLine() calls.