开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜