I have an application that must read it's own output that is written via
Console.WriteLine("blah blah");
I'm trying
Process p = Process.GetCurrentProcess();
StreamReader input = p.StandardOutput;
input.ReadLine();
But it doesn't work because of "InvalidOperationException" at the second line. It says something like "StandardOutput wasn't redirected, or the process has not been started yet" (translated)
How can I read my own output ? Is there another way to do that ? And to be complete how to write my own input ?
The application with the output is running already.
I want to read it's output live in the same application. There is no 2nd app. Only one.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…