我有一个名为"MyApp.exe"的命令行应用程序,我想这样使用:
DoSomething|MyApp.exe
Run Code Online (Sandbox Code Playgroud)
也就是说,DoSomething将字符串输出到标准输出,然后管道将其作为标准输出发送到MyApp.exe.
如何在MyApp.exe中接受此字符串?
UPD.
如果我想测试这个怎么办?我正在使用公共方法来启动我的应用程序活动:
using (MyApp app = new MyApp())
{
result = app.Run(args);
}
If(result!=0) Assert.Fail("Failed");
Run Code Online (Sandbox Code Playgroud)
即我需要在执行Run()之前将一些数据写入输入流
您可以使用Console.In来访问stdin.
或者Console.ReadLine()只是一个捷径Console.In.ReadLine().