If I have a GUI like this:
---------------------
[Button]
---------------------
[RichTextbox_output]
---------------------
Would it be possible to show all:
stdout and stderr in the richTextbox that I can see from ‘output’ diaglog of visual studio?
Thanks in advance.
Stdout in C# is called
Console.Out. Stderr is calledConsole.Error.To solve this you will need to redirect
Console.Out. This can be done usingConsole.SetOut. This will then need to be redirected to a custom stringwriter of your own that will write to the rich text box. This isn’t built into the textbox and you will need to create a stream implementation of your own. One possible solution is to subclassStringWriterand overload theWriteLinemethod to push to your textbox instead.Obviously, if you use more than just
WriteLineyou’ll have to create overloads for those methods as well.The same approach can be taken with
Console.SetErrorfor the stderr stream.