Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Upload Complete Directory Tree to FTP Server with Progress MonitoringDownload: Chilkat .NET Assemblies This example copies a complete directory tree to an FTP server. The directory tree is re-created to exactly duplicate the local directory tree. ' 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 Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.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 ' 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 ' Does the "a" sub-directory on the remote server exist? ' If not, create it and navigate to it. ' (If ListPattern is not a wildcarded filename, then NumFilesAndDirs ' will have the value of 1 or 0, depending on if a file or directory within ' the current remote directory matches the ListPattern.) ftp2.ListPattern = "a" If (ftp2.NumFilesAndDirs = 0) Then ' The directory does not yet exist. success = ftp2.CreateRemoteDir("a") If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If ' The directory is created, now navigate to it... success = ftp2.ChangeRemoteDir("a") If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If End If ' Upload the complete contents of the c:\temp\a directory tree to ' the remote FTP server. The directory structure will be re-created ' on the FTP server and will be identical to the local directory tree. ' The progress bar will update from 0% to 100% in real time as PutTree ' is progressing. success = ftp2.PutTree("c:\temp\a") If (Not success) Then ftp2.SaveLastError("ftpError.txt") Exit Sub End If ftp2.Disconnect() MessageBox.Show("Finished!") End Sub |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.