我正在寻找一个WinForms应用程序的ac#example项目,它将从后台运行的批处理文件的输出重定向到任何类型的WinForms控件.
有什么建议?
我不知道你是否会找到一个直接的例子,但这并不是太难.我没有时间为您编写所有代码,但我可以从MSDN中为您提供代码:
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo =
new ProcessStartInfo("C:\\MyBatchFile.bat" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
StreamReader myStreamReader = myProcess.StandardOutput;
// Read the standard output of the spawned process.
string myString = myStreamReader.ReadToEnd();
myProcess.Close();
// Now you have the output of the batch file in myString
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
358 次 |
| 最近记录: |