c# - Start a process using System.Diagnostics.Process.Start -
i trying execute file stored under program files. program called command prompt, , output information while running. want capture output.
the code below solves half of job: program executed, , console pops showing output in console, cannot capture output:
processstartinfo start = new processstartinfo(); start.workingdirectory = directory; start.filename = filename; start.arguments = arguments; //start.useshellexecute = false; //start.redirectstandardoutput = true; using (process process = process.start(start)) { // code } now using code below capture output:
processstartinfo start = new processstartinfo(); start.workingdirectory = directory; start.filename = filename; start.arguments = arguments; start.useshellexecute = false; start.redirectstandardoutput = true; using (process process = process.start(start)) { using (streamreader reader = process.standardoutput) { string result = reader.readtoend(); console.write(result); } } the program crashes in line execute start command error "the system cannot find file specified"
what don't is, first part of program works, not second.
i have search lot on topic, , there many suggestions have not been able find 1 solves issue.
i using .net 3.5 program prefers due compatibility other parts of program.
Comments
Post a Comment