用c#的Process调用外部exe时,需要同时截取输出和错误流,否则外部程序会一直不退出。
Process p = new Process
....
string outputMessage = p.StandardOutput.ReadToEnd();//截取输出流
string errorMessage = p.StandardError.ReadToEnd(); //截取错误信息
我本来只想要错误信息,但发现如果不截取输出流程序就一直不退出,很迷惑。。。。
用c#的Process调用外部exe时,需要同时截取输出和错误流,否则外部程序会一直不退出。
Process p = new Process
....
string outputMessage = p.StandardOutput.ReadToEnd();//截取输出流
string errorMessage = p.StandardError.ReadToEnd(); //截取错误信息
我本来只想要错误信息,但发现如果不截取输出流程序就一直不退出,很迷惑。。。。