四联光电智能照明论坛

标题: How to print out the value that subprocess prints with C#? [打印本页]

作者: 风火石    时间: 2017-4-13 05:09
标题: How to print out the value that subprocess prints with C#?
http://stackoverflow.com/questio ... ocess-prints-with-c
作者: 风火石    时间: 2017-4-13 05:10
// 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.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
作者: 风火石    时间: 2017-4-13 05:10
ProcessStartInfo psi = new ProcessStartInfo("ruby", "/Users/smcho/Desktop/testit.rb");
psi.RedirectStandardOuput = true;W   
Process proc = new Process(psi);
proc.Start();
StreamReader stdout = proc.StandardOutput;
string line;
while ((line = stdout.ReadLine()) != null)
   Console.WriteLine(line);
作者: admin    时间: 2017-4-13 05:16
// 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.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
作者: admin    时间: 2017-4-13 05:17
ProcessStartInfo psi = new ProcessStartInfo("ruby", "/Users/smcho/Desktop/testit.rb");
psi.RedirectStandardOuput = true;W   
Process proc = new Process(psi);
proc.Start();
StreamReader stdout = proc.StandardOutput;
string line;
while ((line = stdout.ReadLine()) != null)
   Console.WriteLine(line);




欢迎光临 四联光电智能照明论坛 (http://5xhome.com/) Powered by Discuz! X3.2