编写控制台应用程序时,有没有办法创建第二个控制台以在 .NET 中输出? [英] Is there a way to create a second console to output to in .NET when writing a console application?

查看:17
本文介绍了编写控制台应用程序时,有没有办法创建第二个控制台以在 .NET 中输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写控制台应用程序时,有没有办法在 .NET 中创建第二个控制台以输出到?

Is there a way to create a second console to output to in .NET when writing a console application?

推荐答案

好吧,你可以启动一个新的 cmd.exe 进程,并使用 stdio 和 stdout 发送和接收数据.

Well, you could start a new cmd.exe process and use stdio and stdout to send and recieve data.

ProcessStartInfo psi = new ProcessStartInfo("cmd.exe")
{
    RedirectStandardError = true,
    RedirectStandardInput = true,
    RedirectStandardOutput = true,
    UseShellExecute = false
};

Process p = Process.Start(psi);

StreamWriter sw = p.StandardInput;
StreamReader sr = p.StandardOutput;

sw.WriteLine("Hello world!");
sr.Close();

更多信息 MSDN.

这篇关于编写控制台应用程序时,有没有办法创建第二个控制台以在 .NET 中输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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