开发者

error while redirecting process input from file

开发者 https://www.devze.com 2023-02-14 16:14 出处:网络
I\'m receiving an output error while trying to redirect a process input from a file - reading the file content and writing it to the process input.

I'm receiving an output error while trying to redirect a process input from a file - reading the file content and writing it to the process input. the error: <output file> The volume for a file has been externally altered so that the opened file is no longer valid.

the code:

*before foreach loop:

  prc = new Process();
  prc.StartInfo.FileName = prcs;
  prc.StartInfo.UseShellExecute = false;

*inside 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;
      }

* i get the message while writing the command: "text1.txt < sort"

  • another thing, if i run the program in another computer i get the message: " the pipe is being closed" thank you for your help!


It seems that the permission on your output directory are set in a way that prevents Visual Studio from compiling.
Remove any read-only flags from the project's folder and all subdirectories, clear the output folder and, if necessary, take ownership of the folders or give yourself full permissions.

Source: msdn - Visual Studio 2010 fails to build or debug reports error 'Failed to write to output file'.

0

精彩评论

暂无评论...
验证码 换一张
取 消