我在尝试从文件重定向进程输入时收到输出错误 - 读取文件内容并将其写入进程输入。错误:<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 < sort”
- 另一件事,如果我在另一台计算机上运行程序,我会收到消息:“管道正在关闭”谢谢您的帮助!