Hi i want to invoke the Console application from my application but i would like to capture all the output generated in the console. (Remember, i dont want to save the information first in a file and then relist as i would love to receive it as live)
+12
A:
This can be quite easily achieved using the ProcessStartInfo.RedirectStandardOutput Property. A full sample is contained in the linked MSDN documentation; the only caveat is that you may have to redirect the standard error stream as well to see all output of your app.
mdb
2008-10-09 11:32:02
+4
A:
Use ProcessInfo.RedirectStandartOutput to redirect the output when creating your console process.
Then you can use Process.StandardOutput to read the program output.
The second link has a sample code how to do it.
Franci Penov
2008-10-09 11:32:20
A:
Assuming you are invoking the app from console, Doesn't "your_command" > "fileName" do that? Or is it something else
questzen
2008-10-09 11:32:44
A:
Process p = new Process(); // Yeni nesne yarat...
p.StartInfo.UseShellExecute = false; // Shell kullanma...
p.StartInfo.RedirectStandardOutput = true; // Çıkışı yönlendir....
p.StartInfo.FileName = "c:\\python26\\python.exe"; // Python klasörümüz ve derleyicimizin adı...
p.StartInfo.Arguments = "c:\\python26\\Hello_C_Python.py"; // verilecek yani çalıştırılacak python scriptimizin yolu...
livetogogo
2010-05-17 16:18:59