3
我想在c#中读取cmd的连续输出流。我知道我可以重定向标准输出流并读取它。以下是代码:在c#中不断读取控制台流#
System.Diagnostics.ProcessStartInfo pi= new System.Diagnostics.ProcessStartInfo(ProgramPATH,Params);
pi.RedirectStandardOutput = true;
pi.UseShellExecute = false;
pi.CreateNoWindow = true;
System.Diagnostics.Process proc= new System.Diagnostics.Process();
proc.StartInfo = pi;
proc.Start();
string result = proc.StandardOutput.ReadToEnd();
但是,这会给出整个输出一次。如果我用-t
参数发出ping
命令怎么办?我怎样才能不断阅读这个流?
你会介意在这种情况下如何使用事件扩展一点吗?谢谢。 – 2011-02-18 17:25:29