ProcessStartInfo

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Can you let me know why this won't display the standard output on console?

Thanks



Process myProcess = new Process();

ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("ipconfig" );

myProcessStartInfo.Arguments="/all";

myProcessStartInfo.UseShellExecute = false;

myProcessStartInfo.RedirectStandardOutput = true;

myProcess.StartInfo = myProcessStartInfo;

myProcess.Start();

StreamReader myStreamReader = myProcess.StandardOutput;

// Read the standard output of the spawned process.

string myString = myStreamReader.ReadLine();

Console.WriteLine(myString);

myProcess.Close();
 
hi,
you just need to replace :
string myString = myStreamReader.ReadLine();
to
string myString = myStreamReader.ReadToEnd();

hope this helps.
 
Back
Top