ProcessStartInfo
およびProcess
プログラムを起動して(getdiff.exeを実行して)、プログラムが生成するすべての出力を読み込みたいと思います。後でもっと建設的な方法でデータを使用します。データを印刷して確実に機能させるだけです。しかし、プログラムは終了する必要はありません。なぜ誰がそれを知っていますか?進んでいただきありがとうございます。これにプログラムを変更するプロセスを使用しているときにプログラムが終了しない
ProcessStartInfo psi = new ProcessStartInfo("getdiff.exe");
psi.Arguments = "DIFF";
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.WorkingDirectory = "c:\\test";
Process p = Process.Start(psi);
string read = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Console.WriteLine(p);
Console.WriteLine("Complete");
p.Close();
正しく動作してそれを得た:それは関連だ
ProcessStartInfo psi = new ProcessStartInfo("getdiff.exe");
psi.Arguments = "DIFF";
psi.UseShellExecute = false;
psi.RedirectStandardInput = true;
psi.WorkingDirectory = "c:\\test";
Process p = Process.Start(psi);
StreamReader read = p.StandardOutput;
while (read.Peek() >= 0)
Console.WriteLine(read.ReadLine());
Console.WriteLine("Complete");
p.WaitForExit();
p.Close();
このコードを試してみてください?あなたのアプリケーション、または呼び出されたプロセス? – Jaymz
なぜ終了するのですか?コンソールアプリケーションですか?他に何か? –
これは大きなプログラムの関数です。しかし、これだけを実行すると、プログラムは決して終了しません。それは健康ではありません。 – Teletha