C # how can you get the output of another batch file?

I need to use another application (console) to pass some parameter to this program, and inside my C # program, output the output of this program. I would not want to see the console (all invisible to the user). How can i do this?

+5
source share
1 answer
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("YOUPROGRAM_CONSOLE.exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();

StreamReader myStreamReader = myProcess.StandardOutput;
string myString = myStreamReader.ReadLine();
Console.WriteLine(myString);
myProcess.Close();

Source: MSDN

: , Async. , . , .

+17

All Articles