在编写控制台应用程序时,是否可以创建第二个控制台以输出到 .NET 中?
最佳答案
那么,您可以启动一个新的 cmd.exe 进程并使用 stdio 和 stdout 发送和接收数据。
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 的更多信息.
关于c# - 在编写控制台应用程序时,有没有办法创建第二个控制台以在 .NET 中输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/697227/