プロセス入力をファイルからリダイレクトしようとしているときに出力エラーが発生しました - ファイルの内容を読み取ってプロセス入力に書き込んでいます。エラー:<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;
* foreachloop 内:
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 < sort"
- 別のコンピューターでプログラムを実行すると、「パイプが閉じられています」というメッセージが表示されます。