我想使用 C# 启动一个 .exe 程序并从 .exe 生成的 cmd 读取值
.exe 成功启动,但我无法读取值:
这是我的代码:
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = (@"D:\BSC\Thesis\Raphael_Thesis\smiledetector\bin\smiledetector.exe");
start.WorkingDirectory = @"D:\BSC\Thesis\Raphael_Thesis\smiledetector\bin\";
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
//Start the process
using (Process process = Process.Start(start))
{
// Read in all the text from the process with the StreamReader.
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
textBox1.Text = result;
}
}