Console output

class Program {
    static void Main() {
        var process = new Process {
            StartInfo = new ProcessStartInfo {
                CreateNoWindow = true,
                RedirectStandardOutput = true,
                RedirectStandardInput = true,
                UseShellExecute = false,
                FileName = @"C:\temp\Hello.exe",
                Arguments = "world"
            },
            EnableRaisingEvents = true
        };
        process.OutputDataReceived += (sender, e) => {
            Debug.WriteLine(e.Data);
        };
        process.Start();
        process.BeginOutputReadLine();
        process.WaitForExit();
        process.CancelOutputRead();        
    }
}

Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#