Question Output results from TFTP.EXE

mashfield

New member
Joined
Jul 16, 2008
Messages
1
Programming Experience
1-3
Hi all,

I have a function that runs an .exe (TFTP.EXE) and returns the file into my local folder. however.....

I want to return the output (the file) to a TextStream or similar so I can then go on to process the output.

of course I could .sleep(nn) to wait for the text file to be generated and then open the textfile into a textstream however this is neither elegant or robust.

the code below shows how i run the command

application="tftp.exe"
argumentString="192.168.42.123 GET tftpfilename outputfilename.txt" .\mytextfile.txt"


VB.NET:
Private Shared Function runConsoleApp(ByVal application As String, ByVal argumentString As String) As String
        ' Create a new process object
        Dim ProcessObj As Process = New Process()

        ' StartInfo contains the startup information of
        ' the new process
        ProcessObj.StartInfo.FileName = Application
        ProcessObj.StartInfo.Arguments = argumentString

        ' These two optional flags ensure that no DOS window
        ' appears
        ProcessObj.StartInfo.UseShellExecute = False
        ProcessObj.StartInfo.CreateNoWindow = True

        ' If this option is set the DOS window appears again :-/
        ' ProcessObj.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

        ' This ensures that you get the output from the DOS application
        ProcessObj.StartInfo.RedirectStandardOutput = True

        ' Start the process
        ProcessObj.Start()

        ' Wait that the process exits
        ProcessObj.WaitForExit()

        ' Now read the output of the DOS application
        Return ProcessObj.StandardOutput.ReadToEnd()
    End Function

grateful for any help
 
Back
Top