【发布时间】:2011-05-13 21:41:14
【问题描述】:
我有方法:
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?
标签: c# redirect ffmpeg console-application