FTP Code
-
Hey Everyone, I've got a windows application and I want to know if anyone has or knows any code for FTPing files through the system. The code I've got so far is here, but I think I'm missing a class which I've failed to find. If anyone has different code that works, then that would be greatly appreciated! :-) This is what I have so far out of interest: Dim ftp As New Chilkat.Ftp2() <----- This is my error, Chilkat.FTP2() isn't defined!!! Dim success As Boolean ' Any string unlocks the component for the 1st 30-days. success = ftp.UnlockComponent("Anything for 30-day trial") If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ftp.Hostname = "ftp.chilkatsoft.com" 'What's the host name? ftp.Username = "****" 'What's the username? ftp.Password = "****" 'What's the password? 'The default data transfer mode is "Active" as opposed to "Passive". 'Connect and login to the FTP server. success = ftp.Connect() If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ' Change to the remote directory where the file will be uploaded. success = ftp.ChangeRemoteDir("junk") If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ' Upload a file. Dim localFilename As String localFilename = "hamlet.xml" 'Change that to the file I have to upload Dim remoteFilename As String remoteFilename = "hamlet.xml" 'Like wise. success = ftp.PutFile(localFilename, remoteFilename) If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ftp.Disconnect() MsgBox("File Uploaded!") Cheers, Michael :)
-
Hey Everyone, I've got a windows application and I want to know if anyone has or knows any code for FTPing files through the system. The code I've got so far is here, but I think I'm missing a class which I've failed to find. If anyone has different code that works, then that would be greatly appreciated! :-) This is what I have so far out of interest: Dim ftp As New Chilkat.Ftp2() <----- This is my error, Chilkat.FTP2() isn't defined!!! Dim success As Boolean ' Any string unlocks the component for the 1st 30-days. success = ftp.UnlockComponent("Anything for 30-day trial") If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ftp.Hostname = "ftp.chilkatsoft.com" 'What's the host name? ftp.Username = "****" 'What's the username? ftp.Password = "****" 'What's the password? 'The default data transfer mode is "Active" as opposed to "Passive". 'Connect and login to the FTP server. success = ftp.Connect() If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ' Change to the remote directory where the file will be uploaded. success = ftp.ChangeRemoteDir("junk") If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ' Upload a file. Dim localFilename As String localFilename = "hamlet.xml" 'Change that to the file I have to upload Dim remoteFilename As String remoteFilename = "hamlet.xml" 'Like wise. success = ftp.PutFile(localFilename, remoteFilename) If (success <> True) Then MsgBox(ftp.LastErrorText) Exit Sub End If ftp.Disconnect() MsgBox("File Uploaded!") Cheers, Michael :)
Well, first off, do you have the Chilkat FTP library[^]?? And have you added a reference to it in your project??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007