Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
FTP Download File with Progress Monitoring
This VB.NET example program demonstrates how to do an FTP download with progress monitoring. The only real difference between the upload and download examples is that the upload calls PutFile and the download calls GetFile. ' When using events, the Chilkat.Ftp2 object must be a class member or global variable. Dim WithEvents ftp2 As New Chilkat.Ftp2 ' Update the progress bar control with the percent done. Private Sub ftp2_OnFtpPercentDone(ByVal sender As Object, ByVal args As Chilkat.FtpPercentDoneEventArgs) Handles ftp2.OnFtpPercentDone ProgressBar1.Value = args.PercentDone End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ftp2.UnlockComponent("Anything for 30-day trial") ftp2.Hostname = "ftp.chilkatsoft.com" ftp2.Username = "****" ftp2.Password = "****" ' EnableEvents must be set to True for events to fire. ftp2.EnableEvents = True ' Some FTP server may require that the AutoGetSizeForProgress property be set to true. ' Only do this if you see that percent-done progress events are not firing. ftp2.AutoGetSizeForProgress = True ' Connect to the FTP server and login. Dim success As Boolean success = ftp2.Connect() If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If ' Navigate to the "testing" subdirectory on the ftp server. success = ftp2.ChangeRemoteDir("testing") If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If ' Download the file. ' The 1st argument is the remote filename, the 2nd argument ' is the local filename to be created. success = ftp2.GetFile("big.gif", "bigLocal.gif") If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If ftp2.Disconnect() End Sub |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.