2014-03-12 20 views
-1

在數據流任務中,我需要重定向每一行以執行exe,並獲取每行的輸出,與腳本組件類似。SSIS - 在DFT中,如何將每行輸入爲exe並讀取每行的輸出?

我試圖使用腳本組件中的進程,但它引發異常「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(); 
    } 

有什麼建議嗎?我想知道是否有更好的方法來做到這一點?

回答

0

你的錯誤信息是有用的:「StandardOut沒有被重定向...」   既然你想捕捉的輸出,它重定向到目標組件,你不希望更改線路:

myApp.StartInfo.RedirectStandardOutput = false; 

是:

myApp.StartInfo.RedirectStandardOutput = true; 


考慮的例子,在這個環節,在BOL:
ProcessStartInfo.RedirectStandardOutput Property

相關問題