I am using external library ( .dll ), some of it’s methods (including constructors) write stuff to standard output (a.k.a console) because it was intended to be used with console apps. However I am trying to incorporate it into my windows forms applications, so I would like to capture this output and display it in a way I like. I.e. “status” text field within my window.
All I was able to find was ProcessStartInfo.RedirectStandardOutput, though apparently it doesn’t fit my needs, because it is used with an additional application (.exe) in examples. I am not executing external apps, I am just using a dll library.
Create a
StringWriter, and set the standard output to it.Now, anything printed to console will be inserted into the StringWriter, and you can get its contents anytime by calling
stringw.ToString()so then you could do something liketextBox1.AppendText(stringw.ToString());(since you said you had a winform and had a status text field) to set the contents of your textbox.