the problem of redirecting stdout in c#
- by Mher
Could you please explain why the shell redirection doesn't work with System.Diagnostics.Process class? I am trying to redirect the output streams to file with the following snippet:
Process p = new Process();
p.StartInfo = new ProcessStartInfo();
p.StartInfo.FileName = "java.exe";
p.StartInfo.Arguments = @"> c:\Temp\test.log 2>&1";
p.StartInfo.UseShellExecute = true;
p.Start();
The similar code works without problems with Python.
Reading the output streams programmatically doesn't seem a preferable solution in my case because there will be a bunch of processes launched by my application.