シェルを介してコマンドを実行し、C#を使用して完全な出力を文字列として返すにはどうすればよいですか?
PHPのshell_exec()と同等です。
ありがとう、進んだ。
Processクラスを使用する
Process.StandardOutputドキュメントのMSDNドキュメントに例が示されています
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "Write500Lines.exe";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
標準エラーストリームも抽出することをお勧めします。
プロセスクラスの標準出力と標準エラー、およびOutputDataReceivedイベントと ErrorDataReceived受信イベントを確認します。
ここにCodeProjectの記事があり、役立つかもしれません。