You can re-direct outputs of the console application into some streams you can provide by yourself. Use
System.Diagnostics.Process.Start(ProcessStartInfo)
.
You can re-direct two output streams:
System.Diagnostics.Process.StandardError
and
System.Diagnostics.Process.StandardOutput
. You need to use
System.Diagnostics.ProcessStartInfo
in order to specify
System.Diagnostics.ProcessStartInfo.RedirectStandardError
or
System.Diagnostics.ProcessStartInfo.RedirectStandardErrorRedirectStandardOutput
.
You can use file stream for redirection of
StandardError
or
StandardOutput
or some other stream, as these properties should of the type
System.IO.StreamReader
. You can create your own class derived from
System.IO.StreamReader
or use its constructor accepting the parameter of the abstract class
System.IO.Stream
, so you can also use your own stream class derived from
System.IO.Stream
. In this way, you can implement any stream type to your requirements to be used for stream re-direction.
(One typical example of this re-direction feature is running a compiler or а linker (or other tool used for a build step) under IDE, where a compiler or а linker output (errors and warnings, in particular) is displayed in IDE control immediately as the build goes.)
See:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.io.streamreader.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.io.stream.aspx[
^].
—SA