[英]How do I tie into the standard input and output with C#?
What I am trying to do is see if I can use the MinGW C++ compiler and debugger to compile files using a C# app. 我想要做的是看看我是否可以使用MinGW C ++编译器和调试器来使用C#app编译文件。 I want to be able to read the output and write to the input (input mainly for the debugger) within the C# app whenever I need to.
我希望能够在需要时读取输出并写入C#应用程序内的输入(主要用于调试器的输入)。
Reading from output will be much like Visual Studio does in its 'Output' window durring a project build. 从输出中读取将非常像Visual Studio在项目构建期间在“输出”窗口中执行的操作。
I have used System.Diagnostics.Process
before but haven't been able to figure out how to interact with the processes. 我之前使用过
System.Diagnostics.Process
,但一直无法弄清楚如何与进程交互。
So, how do I take control of std input/output? 那么,我如何控制std输入/输出?
The following question shows how to capture standard output: 以下问题显示了如何捕获标准输出:
How do I run a Console Application, capture the output and display it in a Literal? 如何运行控制台应用程序,捕获输出并将其显示在Literal中?
Writing to standard input is similar -- set RedirectStandardInput to true, and use a streamwriter to write to it: 写入标准输入类似 - 将RedirectStandardInput设置为true,并使用streamwriter写入它:
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardinput.aspx http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.redirectstandardinput.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.