2011-07-11 11 views
1

私は、一連の操作を行い、各操作の完了後にメッセージを出すコンソールアプリケーションを持っています。私は私のコンソールアプリケーションを実行すると、私のコンソールウィンドウ内のメッセージは、次のようになります。コンソールウィンドウからWinformアプリケーションへの出力を取得する

Checking prerequisites... 
Completing prerequisites.. 
Performing installation... 
Completing installation... 
Done..! 

今私はProcess.StartInfoを()を使用して、私のC#のWindowsアプリケーションのいずれかから、このコンソールアプリケーションを実行しています。 コンソールアプリケーションでスローされたすべてのメッセージをアプリケーションのウィンドウ形式で表示する必要があります。

これはできますか?

ありがとうございました。

+0

[.NETのコンソール出力(C#)をキャプチャ](http://stackoverflow.com/questions/186822/capturing-the-console-output-in-net-c)の可能重複 – RvdK

答えて

1

ここを見て。完全なサンプルは、リンクMSDN documentationに含まれています。

Process compiler = new Process(); 
compiler.StartInfo.FileName = "csc.exe"; 
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs"; 
compiler.StartInfo.UseShellExecute = false; 
compiler.StartInfo.RedirectStandardOutput = true; 
compiler.Start();  

Console.WriteLine(compiler.StandardOutput.ReadToEnd()); 

compiler.WaitForExit(); 
関連する問題