I have a module that reads the StandardError of a process. Everything works fine, but I want to do something different. I don’t know how to redirect stdin like the native way:
app1.exe -someargs | app2.exe -someargs
Where app2 reads all the stdout of app1 in its stdin.
Have a look at the MSDN reference documentation for the following (both to be found in the
System.Diagnosticsnamespace):Process.StandardInputProcessStartInfo.RedirectStandardInput.There’s an example showing how to start a child process and write directly to its standard input.
For your particular example, here’s how you set things up:
app1 starts app2 as a child process using the
Processclass (see links above).app1 writes to app2‘s standard input by writing to the
.StandardInputstream of theProcessobject associated with app2.app2 just reads lines from its standard input (e.g. via
Console.ReadLine()).