在数据流任务中,我需要将每一行重定向到 exe 并获取每一行的输出,类似于脚本组件。
我尝试在脚本组件中使用 Process,但它抛出异常“StandardOut 尚未重定向或进程尚未启动。”。脚本组件中使用的代码是:
Process myApp = new Process();
myApp.StartInfo.FileName = @"Someexe.exe";
myApp.StartInfo.Arguments = "param1";
myApp.StartInfo.UseShellExecute = false;
myApp.StartInfo.RedirectStandardOutput = false;
myApp.Start();
while (!myApp.HasExited)
{
string result= myApp.StandardOutput.ReadToEnd();
}
有什么建议么?我想知道是否有更好的方法来做到这一点?