ftp a local file

mtaylor314

Member
Joined
Nov 30, 2006
Messages
19
Location
Cleves, OH
Programming Experience
Beginner
VB.NET:
    Const localFile As String = "C:\Test.txt"
    Const remoteFile As String = "/bin/Testing/Test.txt"
    Const host As String = "ftp://ftp.website.com"
    Const UserName As String = "user"
    Const Password As String = "******"

        Dim URI As String = host & remoteFile
        Dim ftp As FtpWebRequest = CType(FtpWebRequest.Create(URI), FtpWebRequest)

        ftp.Credentials = New NetworkCredential(UserName, Password)

        ftp.KeepAlive = False

        ftp.UseBinary = True

        ftp.Method = WebRequestMethods.Ftp.UploadFile
need a little help as to where to pass the local file name so it knows what to upload.
 
For a simple operation like that I'd suggest using a WebClient instead. If this forms part of a larger FTP client then the FtpWebRequest/FtpWebResponse classes would be a better bet though.
 
Back
Top