Ohad's Blog

Lets talk about .net !

Mirror at:
blogs.microsoft.co.il

News

         Ohad Israeli's Facebook profile

Grab this badge here!

C# Code Snippts

Favorite Blogs

Israeli .Net Bloggers

Process.Start and redirect to text file / pipe another process

When you want to spawn a process, but want the process to dump to a text file you might use :

Process.Start("cmd.exe", "/c foo.exe -arg >" + dumpDir + "\\foo_arg.txt");

In case you don't need the file "foo_arg.txt" itself but want the actual output its possible to set ProcessStartInfo.RedirectStandardOutput flag to true and then read the process output using Process.StandardOutput stream.

Another option is to use Process Start for piping the output of the first process to the second :

Process.Start("cmd.exe", "/c foo.exe -arg " + "| bar.exe");

 

Comments

No Comments