FTP Process issues

james9299

New member
Joined
Nov 22, 2007
Messages
2
Programming Experience
Beginner
Hello Everyone

Quick question I am using the command:

ftp -s:script.txt > output.txt

To run an ftp script and log the results in output.txt

i need this to be automated in my vb.net application.

So far i have:

VB.NET:
        Dim startInfo As System.Diagnostics.ProcessStartInfo
        Dim pStart As New System.Diagnostics.Process
        
        startInfo = New System.Diagnostics.ProcessStartInfo("ftp")

        pStart.StartInfo = startInfo
        pStart.StartInfo.Arguments() = "-s:c:\script.txt"
        pStart.Start()
        pStart.WaitForExit() 'Your code will halt until the exe file has executed.

But i have no idea how to include the "> output.txt" for the logging as it isn't an argument and adding it to the arguments stops the script from being ran.

Any Help would be much appreciated as always.

Thanks in advance
James
 
Last edited by a moderator:
But i have no idea how to include the "> output.txt" for the logging as it isn't an argument
It isn't an argument for ftp.exe but it is for cmd.exe. So you can run process "cmd.exe" with arguments "/c ftp.exe -s:c:\script.txt >c:\output.txt"

You can also run the ftp.exe process and use RedirectStandardOutput to get the output.

Another way around is using FTP networking functionality from System.Net namespace. There is a WebClient class that can do simple UL/DL and a FtpWebRequest class that have more options.
 
Back
Top