0

I want to redirect output to a file but I don't want to do it through the arguments like so:

ProcessStartInfo sInfo = new ProcessStartInfo();
sInfo.FileName = "test.exe";
sInfo.Arguments = "> test.log";
Process myProc = new Process();
myProc.StartInfo = sInfo;
myProc.Start();

It seems if I do that, it just flat out doesn't work. Any ideas how or a way around it?

Trevor
  • 361
  • 1
  • 4
  • 12
  • possible duplicate of [redirecting output to the text file c#](http://stackoverflow.com/questions/16256587/redirecting-output-to-the-text-file-c-sharp) – Jay Riggs Mar 19 '14 at 23:39

1 Answers1

0

The best way is to use a stream reader : start the process first using ProcessStartInfo class then use the RedirectStandardOutput and put it as a boolean true, now start your process and read your file with StreamReader, more help can be found HERE.

Bouzenzel
  • 187
  • 1
  • 1
  • 18