C#Windows窗体的.Net和DOS控制台 [英] C# Windows Form .Net and DOS Console

查看:332
本文介绍了C#Windows窗体的.Net和DOS控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个执行的批处理文件的窗口形式。我想要的一切,happends在我的控制台在我的形式传输到面板。我怎样才能做到这一点?如何让我的DOS控制台的comunicate我的Windows窗体面板???

I have a windows form that executes a batch file. I want to transfer everything that happends in my console to a panel in my form. How can I do this? How can my DOS console comunicate with my windows form panel???

感谢

推荐答案

您可以从您的窗体应用程序调用DOS或批处理程序,并将输出重定向到一个字符串:

You can call the DOS or batch program from your Form application and redirect the output to a string:

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( );
}

这篇关于C#Windows窗体的.Net和DOS控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆