user393148
user393148

Reputation: 957

Capturing output of process invoked through debugger

I currently run my program through debugger.

P.FileName = "windbg.exe"
P.Arguments = "-g -G foo.exe arg1 arg2"

If I do redirect on process P, I dont get the output of foo.exe, How can I get the output of foo.exe to be saved to a log file and also to write to console?

Thanks.

Adding code based on comment below. But this is not what I am looking for. I need the output of foo.exe.

P.FileName = "windbg.exe"
P.Arguments = "-g -G foo.exe arg1 arg2"

p.RedirectOutput = true;
p.start();
StreamReader outputReader= p.StandardOutout
p.waitforexit();

string displayText = "Output" + Environment.NewLine + "==============" + Environment.NewLine;
                       displayText += outputReader.ReadToEnd();
Console.writeline(displayText);

Can anyone help? I havent found any solution for this...

Upvotes: 2

Views: 195

Answers (1)

BrokenGlass
BrokenGlass

Reputation: 160992

This is described in depth in the code project article "How to redirect Standard Input/Output of an application"

Upvotes: 1

Related Questions