Run a second console app and read its output.
Run a second console app and read its output.: "using System;
using System.Diagnostics;
namespace ConsoleApplication8
{
class Class1
{
static void Main(string[] args)
{
ProcessStartInfo proc = new ProcessStartInfo(); / a process holder */
proc.FileName = 'ping.exe';
proc.RedirectStandardInput = false;
proc.RedirectStandardOutput = true;
proc.Arguments = '127.0.0.1';
proc.UseShellExecute = false; /*do not show console for the process - a must*/
Process p = Process.Start(proc);
string res;
res = p.StandardOutput.ReadToEnd();
System.Console.WriteLine(res);
p.WaitForExit(); /*wait indefinitely for the associated process to exit*/
}
}
}
"
0 Comments:
Post a Comment
<< Home