sai*_*dhu 3 .net c# outputstream console-application
我正在执行一个C#程序,即来自另一个C#程序的.exe.但.exe在其程序中有一些Console.WriteLine().我想把标准输出到我的C#程序中.
例如,
考虑一个C#可执行文件,即1.exe,还有另一个程序2.cs.
我从2.cs 1.exe打电话.现在控制台从1. exe显示一些输出.但是我希望我的程序中的输出2.cs. 用于向用户显示信息.
可能吗?请帮忙
谢谢Sai sindhu
Dor*_*hen 10
您可以使用ProcessStartInfo.RedirectStandardOutput属性
Process compiler = new Process();
compiler.StartInfo.FileName = "csc.exe";
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();
Console.WriteLine(compiler.StandardOutput.ReadToEnd());
compiler.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2722 次 |
| 最近记录: |