Redirect StandardOutput to a file.

  • Thread starter Thread starter Franco Gustavo
  • Start date Start date
F

Franco Gustavo

How can redirect the standard output to a file from inside the same process.



It can be easily done if one process launches another process with
startinfo.RedirectStandardOutput to true.



Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "test.exe";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();



But I don't want this...



I want to launch just one process and inside itself control the own standard
output.



Basically my problem is that my process is using a couple external libraries
(dlls), and those send useful information to the standardOutput, I need to
capture that info.



Thanks,

Gustavo
 
Back
Top