Created
March 13, 2012 12:30
-
-
Save CharlTruter/2028487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RunProcess(string path) | |
{ | |
using (Process process = new Process()) | |
{ | |
// This sets up the output redirection | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
// Specify the path to the file here | |
process.StartInfo.FileName = path; | |
// Start the process here | |
process.Start(); | |
// This reads the output from the process and stores it in a string | |
string output = process.StandardOutput.ReadToEnd(); | |
// Wait for the process to finish execution | |
process.WaitForExit(); | |
Console.WriteLine("Output is {0}", output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment