Skip to content

Instantly share code, notes, and snippets.

@jhgbrt
jhgbrt / ProcessHelper.cs
Last active September 30, 2015 15:18
C#/.Net class for launching a CommandLine process and capturing stdout/stderr
public class ProcessHelper
{
/// <summary>
/// Starts a command line process, redirecting both StdOut and StdErr.
/// </summary>
/// <param name="fileName">Path to the executable</param>
/// <param name="arguments">Command line arguments</param>
/// <param name="onErr">Action to perform when data from the child process is read from StdErr. The action takes 2 parameters: a Process instance (representing the child process) and a string (the data it wrote to StdErr)</param>
/// <param name="onOut">Action to perform when data from the child process is read from StdOut. The action takes 2 parameters: a Process instance (representing the child process) and a string (the data it wrote to StdOut)</param>
/// <returns></returns>