Redirect Raw console output in separate program C#
I know you can use something like the following to receive output from one program. However, if that program uses RAW mode output (like a progress bar) how do I display that in my own programs output?
var proc = new Process();
proc.StartInfo.FileName = cmdPath;
// set up output redirection
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.EnableRaisingEvents = true;
proc.StartInfo.CreateNoWindow = true;
// see below for output handler
proc.ErrorDataReceived += proc_DataReceived;
proc.OutputDataReceived += proc_DataReceiv开发者_开发问答ed;
proc.Start();
proc.BeginErrorReadLine();
proc.BeginOutputReadLine();
proc.WaitForExit();
Try this:
var output = proc.StandardOutput.ReadToEnd();
精彩评论