Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run console application in C# with parameters

How can I run a console application in C#, passing parameters to it, and get the result of the application in Unicode? Console.WriteLine is used in the console application. Important point is write Unicode in Console Application.

like image 351
Sajad Bahmani Avatar asked Jun 28 '11 19:06

Sajad Bahmani


1 Answers

Sample from MSDN

 // Start the child process.
 Process p = new Process();
 // Redirect the output stream of the child process.
 p.StartInfo.UseShellExecute = false;
 p.StartInfo.RedirectStandardOutput = true;
 p.StartInfo.FileName = "Write500Lines.exe";
 p.Start();
 // Do not wait for the child process to exit before
 // reading to the end of its redirected stream.
 // p.WaitForExit();
 // Read the output stream first and then wait.
 string output = p.StandardOutput.ReadToEnd();
 p.WaitForExit();
like image 64
Jakub Šturc Avatar answered Oct 12 '22 00:10

Jakub Šturc