Redirect process output C#

Use RedirectStandardOutput. Sample from MSDN: // Start the child process. Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName = “Write500Lines.exe”; p.Start(); // Do not wait for the child process to exit before // reading to the end of its redirected stream. // … Read more

C# get process output while running

Use Process.OutputDataReceived event from the process, to recieve the data you need. Example: var myProc= new Process(); … myProc.StartInfo.RedirectStandardOutput = true; myProc.OutputDataReceived += new DataReceivedEventHandler(MyProcOutputHandler); … private static void MyProcOutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { // Collect the sort command output. if (!String.IsNullOrEmpty(outLine.Data)) { …. } }