I want to capture the output of a console application in my C# code, but without affecting the output of the program itself.
I know how to launch a console application and catch its output (it's described here). But all of the solutions there set RedirectStandardOutput=true
, which means that the window being opened just stays black. This is of course bad if the window would show progress or require user input. Is there a way to capture the output without changing RedirectStandardOutput
to true?
EDIT Here it says "By setting RedirectStandardOutput to true to redirect the StandardOutput stream, you can manipulate or suppress the output of a process. For example, you can filter the text, format it differently, or write the output to both the console and a designated log file.". But they don't explain how filtering would work. Can I write to the console of another process?
EDIT2 The linked question doesn't help me, it seems. Since my own application is a WPF GUI app, I can't just write to the console. I need to write to the console of the target app, not my own.