-1

i want to read the data from console(cmd) i tried this code

compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();
compiler.StandardOutput.ReadToEnd();

but its not working

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Arpit Suthar
  • 754
  • 1
  • 5
  • 19

1 Answers1

0

try this

Process compiler = new Process();
compiler.StartInfo.FileName = "SOME.exe";
compiler.StartInfo.Arguments = "SOME ARG";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();    

var result=compiler.StandardOutput.ReadToEnd();

compiler.WaitForExit();
santosh singh
  • 27,666
  • 26
  • 83
  • 129
  • That may hang. Use http://stackoverflow.com/questions/15032643/get-values-from-process-standardoutput – Bogdan Mar 24 '14 at 06:37