How can I upload text files using FTP server e.g. ftp://ftp.example.com (with username and password) in Microsoft Visual Basic 2005 express edition... ?
Printable View
How can I upload text files using FTP server e.g. ftp://ftp.example.com (with username and password) in Microsoft Visual Basic 2005 express edition... ?
You can use the UploadFile method present in the 'My.Computer.Network' class to upload and download files from FTP. Example usage of UploadFile:
vb Code:
My.Computer.Network.UploadFile(filenameToUpload, "ftp://ftp.example.com", "ftpUsername", "ftpPassword", True, 1000000)
Just replace file name, credentials and ftp address to upload your file.
Is there any error handling associated with this code (I don't wanna use MsgBox here). DownloadFile is a BackgroundWorker Control ... Label1 is a label control to show error.
THIS CODE ISN"T WORKING AT ALL ... (InvalidOperationException error is displayed)
vb Code:
Private Sub DownloadFile_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles DownloadFile.DoWork On Error GoTo ErrorOccExcep My.Computer.Network.DownloadFile("http://www.example.com/file.txt", "C:\file_temp.txt") ErrorOccExcep: Label1.Text = "Error occurred!" End Sub
Help please ... :) :)
No need to shout, just search the forum.
Example; http://www.vbforums.com/showthread.php?t=468649