我有一个执行批处理文件的Windows窗体.我想将我控制台中发生的所有事情转移到我表单中的面板.我怎样才能做到这一点?我的DOS控制台如何与我的Windows窗体面板通信???
谢谢
您可以从Form应用程序中调用DOS或批处理程序,并将输出重定向到字符串:
using (var p = new System.Diagnostics.Process( ))
{
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = PathToBatchFile;
p.StartInfo.Arguments = args;
p.Start( );
string o = p.StandardOutput.ReadToEnd( );
p.WaitForExit( );
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7839 次 |
| 最近记录: |