msdn中有呀 详见ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.htm 下面的示例生成一个新的用户定义的可执行文件,并读取它的标准输出。然后控制台上会显示输出。[Visual Basic] Dim myProcess As New Process() Dim myProcessStartInfo As New ProcessStartInfo("Process_StandardOutput_Sample.exe") myProcessStartInfo.UseShellExecute = False myProcessStartInfo.RedirectStandardOutput = True myProcess.StartInfo = myProcessStartInfo myProcess.Start()Dim myStreamReader As StreamReader = myProcess.StandardOutput ' Read the standard output of the spawned process. Dim myString As String = myStreamReader.ReadLine() Console.WriteLine(myString) myProcess.Close()[C#] Process myProcess = new Process(); ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("Process_StandardOutput_Sample.exe" ); myProcessStartInfo.UseShellExecute = false; myProcessStartInfo.RedirectStandardOutput = true; myProcess.StartInfo = myProcessStartInfo; myProcess.Start();StreamReader myStreamReader = myProcess.StandardOutput; // Read the standard output of the spawned process. string myString = myStreamReader.ReadLine(); Console.WriteLine(myString); myProcess.Close();
详见ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfsystemdiagnosticsprocessclassstandardoutputtopic.htm
下面的示例生成一个新的用户定义的可执行文件,并读取它的标准输出。然后控制台上会显示输出。[Visual Basic]
Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("Process_StandardOutput_Sample.exe")
myProcessStartInfo.UseShellExecute = False
myProcessStartInfo.RedirectStandardOutput = True
myProcess.StartInfo = myProcessStartInfo
myProcess.Start()Dim myStreamReader As StreamReader = myProcess.StandardOutput
' Read the standard output of the spawned process.
Dim myString As String = myStreamReader.ReadLine()
Console.WriteLine(myString)
myProcess.Close()[C#]
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo("Process_StandardOutput_Sample.exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();StreamReader myStreamReader = myProcess.StandardOutput;
// Read the standard output of the spawned process.
string myString = myStreamReader.ReadLine();
Console.WriteLine(myString);
myProcess.Close();