5
我的方法:为什么这种方法重定向我的输出从.exe [ffmpeg]?
public static string StartProcess(string exePathArg, string argumentsArg, int timeToWaitForProcessToExit)
{
string retMessage = "";
using (Process p = new Process())
{
p.StartInfo.FileName = exePathArg;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = argumentsArg;
p.StartInfo.UseShellExecute = false;
try
{
p.Start();
StreamReader myOutput = p.StandardOutput;
retMessage = "STANDARD OUTPUT: " + myOutput.ReadToEnd();
p.WaitForExit(timeToWaitForProcessToExit);
}
catch (Exception ex)
{
retMessage = "EXCEPTION THROWN: " + ex.ToString();
}
finally
{
try
{
p.Kill();
}
catch { }
}
}
return retMessage;
}
但它不重定向我的输出retMessage。任何任何想法?我测试了bat文件中的参数,并且输出肯定是输出。
干杯, 皮特
也许进程不会写入StandardOutput,而只写入StandardError? – dtb 2010-11-22 15:03:47