c# - Running cmd commands -


i run cmd command in c# , somehow crashes. mean, when work smaller files (i run kind of converter software) suceeds, when try larger ones crashes. want know where. , therefore run command , see details, progress. when run normally, hand in command line, writes : welcome ... progress : ... , on. how see in c#? see blank black stuff.

here's code. tried write out standardoutput, standarderror, seems good. chance see details of stuff running.

process = new system.diagnostics.process(); startinfo = new system.diagnostics.processstartinfo(); startinfo.filename = "cmd.exe"; startinfo.workingdirectory = dir.parent.fullname; startinfo.windowstyle = system.diagnostics.processwindowstyle.normal; startinfo.useshellexecute = false; startinfo.redirectstandardoutput = true; startinfo.redirectstandardinput = true; startinfo.redirectstandarderror = true; process.startinfo = startinfo; process.start();  process.standardinput.writeline(@"make html"); k = new streamreader(process.standardoutput.basestream); process.standardinput.writeline(@"exit"); k.readtoend(); 

thank guys, hope can help. have nice day!

edit: see output, writing make html > output.txt problem is, why can run same command cmd, hand, , why cannot c# thanks

you on right track redirection, have hook want it...

please check post here portion...

startinfo.outputdatareceived += dosoutputresultshandler;  stringbuilder dosoutputresults = new stringbuilder();   protected void dosoutputresultshandler(object sendingprocess,    system.diagnostics.datareceivedeventargs outline) {    if (!string.isnullorempty(outline.data))       // track data normal output string builder       dosoutputresults.append(environment.newline + outline.data); } 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -