Skip to content

Instantly share code, notes, and snippets.

@CharlTruter
Created March 13, 2012 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CharlTruter/2028487 to your computer and use it in GitHub Desktop.
Save CharlTruter/2028487 to your computer and use it in GitHub Desktop.
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