15

次のようにコマンドプロンプトコマンドを実行しています。

string cmd = "/c dir" ; 
System.Diagnostics.Process proc = new System.Diagnostics.Process(); 
proc.StartInfo.FileName = "cmd.exe";
proc.StartInfo.Arguments = cmd; 
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true; 
proc.Start();

コマンドの出力を取得するにはどうすればよいですか?

4

1 に答える 1

20

これを試して

string output = proc.StandardOutput.ReadToEnd();
于 2013-04-04T20:25:59.453 に答える