C# Windows Form .Net 和 DOS 控制台

标签 c# .net

我有一个执行批处理文件的 Windows 窗体。我想将我控制台中发生的所有事情转移到我表单中的面板中。我怎样才能做到这一点?我的 DOS 控制台如何与我的 Windows 窗体面板通信???

谢谢

最佳答案

您可以从您的表单应用程序调用 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( );
}

关于C# Windows Form .Net 和 DOS 控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1040706/

相关文章:

c# - 使 +y 向上,移动原点 C# System.Drawing.Graphics

c# - 在 iframe 中使用 RedirectToAction 后,ASP.NET MVC session 会重置

c# - SDK 路径在 Notepad++ plugin.net 中为空

c# - 使用外部列表来排序 linq 查询

.net - 记录 ASP.NET MVC 性能指标

c# - ASP.NET 中的两种数据绑定(bind)方式

c# - 如何在 app.xaml 中将 datagrid SelectedIndex 设置为 -1

.net - 为什么不能在PowerShell中的事件处理程序中设置表单的DialogResult?

c# - System.Drawing 可以在 Azure 网站中使用吗?

c# - 将 html 文本框值从用户控件传递到 aspx 页面