我在尝试从文件重定向进程输入时收到输出错误 - 读取文件内容并将其写入进程输入。
错误:<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&lt; sort”
答案 0 :(得分:0)
输出目录的权限似乎是以阻止Visual Studio编译的方式设置的 从项目的文件夹和所有子目录中删除所有只读标志,清除输出文件夹,如有必要,取得文件夹的所有权或给自己完全权限。
来源:msdn - Visual Studio 2010 fails to build or debug reports error 'Failed to write to output file'.