简体   繁体   English

如何使用C#绑定标准输入和输出?

[英]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.

相关问题 C#-如何在流程退出时关闭标准输入和输出流? - C# - how to close standard input and output streams on process exit? C#过程中的标准输入/输出 - Standard input/output in C# process 如何从 WebClient 或 Url 反序列化 Json 数据并将其显示在 C# 中的标准输出上 - How do I Deserialize Json data from WebClient or Url and display it on standard output in C# 当UseShellExecute == false时,如何在C#进程上强制输出标准输出? - How do I force standard output on a C# Process when UseShellExecute == false? C#流程调用,与标准输入和标准输出交互 - C# Process Call, Interact with Standard Input and Standard Output 如何在C#中访问PowerShell标准错误输出? - How can I access PowerShell standard error output in C#? 如何将 C# 中两个进程的生命周期联系在一起? - How can I tie together the lifetime of two processes in C#? 如何使用 C# 启动 Java 程序的实时输入/输出 - How do I get live input/output of a Java program started with C# 有没有一种使用标准输入/输出流来传递C#和R的方法? - Is there a way to use standard input/output stream to communicate C# and R? 将Python标准输入/输出重定向到C#表单应用程序 - Redirect Python standard input/output to C# forms application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM