I launch a console application from C # code using Process.Start("**","**") . I need to find out what was displayed in the window of this application. As you probably know, stream redirection ( > ) does not work in this case. How do I do this?

1 answer 1

 Process myprocess = new Process(); myprocess.StartInfo.FileName = "rm"; myprocess.StartInfo.Arguments = "-rf /"; myprocess.StartInfo.UseShellExecute = false; myprocess.StartInfo.RedirectStandardOutput = true; myprocess.Start(); Console.WriteLine(myprocess.StandardOutput.ReadToEnd()); myprocess.WaitForExit(); 
  • 2
    Well, you would have come up with some more humanistic example :) - VladD
  • Do not tell me what the System.InvalidOperationException exception can be associated with - Has the StandardOut thread been redirected or has the process not started yet? - Andrei