c# - redirecting stdout to a file question? -


hi why getting access denied error when try execute process? running (msbuild "projectfile here" "additional args") command new process

public bool cmdexecute(string command,string args)      {              bool isok = true;          try          {              using (system.diagnostics.process proc = new system.diagnostics.process())              {                   proc.enableraisingevents = false;                  proc.startinfo.useshellexecute = false;                  proc.startinfo.redirectstandardoutput = true;                  proc.startinfo.filename = command;                  proc.startinfo.arguments = args;                  // console.out.writeline(proc.startinfo.arguments);                   proc.start();                  string output = proc.standardoutput.readtoend();                proc.waitforexit();                console.writeline(output);              }               }          }          catch(exception e)          {             console.writeline(e.message);              isok = false;          }          return isok;         } 

read docs on process.startinfo.redirectstandardoutput. you're not using correctly.

http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardoutput.aspx

if you're using redirectstandardoutput, should reading process.standardoutput , process.standarderror , doing it.

i suspect you're getting access denied resulting command line doesn't make sense. get:

msbuild args &> p:\\build.txt 

the extraneous ampersand (&) going cause problems.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -