Creating an "output window"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody!

I'm creating a very simple VB .NET application that needs to launch the
command line ml.exe compiler.

At the moment I'm redirecting ML's output to a text file and then my app
reads its content and puts it to a textbox for the results.

Is it possible to redirect ML's output as VS does, I mean the output given
line by line as if it was in a console window? A practical example is given
by VS IDE when it launches .NET compilers and output progress is shown in the
output window.

Many thanks,
Progalex
 
Take a look at System.Diagnostics.Process. Check out the help for the
StandardOutput property, it has good examples.

Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("ml.exe")
myProcessStartInfo.UseShellExecute = False
myProcessStartInfo.RedirectStandardOutput = True
myProcess.StartInfo = myProcessStartInfo
myProcess.Start()

Dim myStreamReader As StreamReader = myProcess.StandardOutput
' Read the standard output of the spawned process.
Dim myString As String = myStreamReader.ReadLine()
Console.WriteLine(myString)
myProcess.Close()

Hope this helps,

Phil Harvey
 
Back
Top