我在嘗試重定向文件的過程輸入時收到輸出錯誤 - 讀取文件內容並將其寫入過程輸入。 錯誤:<output file> The volume for a file has been externally altered so that the opened file is no longer valid.
從文件重定向過程輸入時出錯
代碼:
*前foreach循環:
prc = new Process();
prc.StartInfo.FileName = prcs;
prc.StartInfo.UseShellExecute = false;
*內部foreach循環:
prc = new Process();
prc.StartInfo.FileName = prcs;
prc.StartInfo.UseShellExecute = false;
if (prcs == asProcesses[0])//first process - only redirect output
{
prc.StartInfo.RedirectStandardInput = true;
prc.StartInfo.RedirectStandardOutput = true;
prc.Start();
sw = prc.StandardInput;
StreamReader sr1 = new StreamReader(sInRedirect);
while ((outputLine = sr1.ReadLine()) != null)
{
sw.Write(outputLine);
sw.WriteLine();
}
sr = prc.StandardOutput;
}
*我得到的消息,而寫命令:「 text1.txt <類別「
- 另一件事,如果我在另一臺電腦上運行該程序,我收到消息: 「管道正在關閉」 感謝您的幫助!
你將文件寫入哪種位置? – Oded 2011-03-02 20:49:10
outputline是一個字符串 – 2011-03-02 20:56:50
這不是我所要求的。什麼是'InRedirect'?什麼樣的位置? – Oded 2011-03-02 20:59:31