在编写控制台应用程序时,有没有办法创建第二个控制台以在 .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 http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput(vs.71).aspx.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)