tags:

views:

12

answers:

1

Is there a simple way how to launch a process in .NET and redirect its output(s) to a file? I know that in Win API I can pass a file handle to the CreateProcess function. In .NET I can do something like

startInfo.RedirectStandardOutput = true;

and then use BeginOutputReadLine and StandardOutput to get the data and save it to a file. But it seems a bit overhead compared to what OS can handle itself.

Thanks

A: 

you can run file as someApp.exe >logfile.txt

Andrey
I'm afraid I can't run this from .NET. I could run something like "cmd.exe /c someApp.exe > file.txt" but that's still a workaround.
Elephantik
@Elephantik yes, it might be required. What you want is essentially workaround.
Andrey
I wouldn't agree that a feature supported by OS is workaround ;)
Elephantik
@Elephantik i don't understand you. this method is pretty valid.
Andrey