Redirect StandardOutput to a file.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top