This page is likely outdated (last edited on 17 Oct 2007). Visit the new documentation for updated content.
Howto PipeOutput
This How-To shows how to get the output of a child process.
// This sample runs grep and extracts all the lines that match
// the line "miguel" from /etc/passwd
using System;
using System.Diagnostics;
class Test
{
public static void Main ()
{
ProcessStartInfo psi = new ProcessStartInfo ();
psi.FileName = "grep";
psi.Arguments = "miguel /etc/passwd";
psi.RedirectStandardOutput = true;
psi.UseShellExecute = false;
Process p = Process.Start (psi);
string ret = p.StandardOutput.ReadToEnd ();
p.WaitForExit ();
Console.WriteLine (ret);
}
}
\