FTP Progress Monitoring

This post points to the various examples and blog posts scattered among the chilkatsoft.com, example-code.com, and cknotes.com involving progress monitoring of  FTP uploads and downloads using the Chilkat FTP2 ActiveX, .NET component, and C++ libs.

Important for Monitoring Upload Progress: The SendBufferSize property is set to a large value (512K) to maximize performance.  Unfortunately, this usually ruins the frequency of “percent done” callbacks for upload (not downloads, just uploads).  To improve the upload “percent done” callback frequency, set the SendBufferSize property to a smaller value, such as 4K.  It may slow the upload transfer rate a bit, but it improves the progress monitoring capability.  You can experiment with different values for SendBufferSize to determine what best suits your needs.

Monitoring Download Percent-Done: Be sure to read about the AutoGetSizeForProgress and the ProgressMonSize properties in the Chilkat online reference documentation.  Depending on your FTP server, it may be necessary to set the AutoGetSizeForProgress equal to True to properly receive percent-done event callbacks.  In most cases, neither property is needed — it entirely depends on whether the FTP server provides file-size information in the intermediate response to a “RETR” FTP protocol command.

FTP2 Events in C# and VB.NET:

FTP2 Events in VB6

FTP2 Events in C++

FTP2 Events in FoxPro:

More Information:

Encryption Progress Monitoring


Is there a way to encrypt a file with progress monitoring?  Huge files can take a while and it seems like the app is hanging.


Yes, here is the sample VB6 code:

Public WithEvents myCrypt As ChilkatCrypt2

' ....

Private Sub myCrypt_PercentDone(ByVal pctDone As Long)

    ProgressBar1.Value = pctDone
End Sub

Private Sub Command2_Click()

    Set myCrypt = New ChilkatCrypt2
    success = myCrypt.UnlockComponent("test")
    ' ...

    success = myCrypt.CkEncryptFile("c:/temp/big.txt", "c:/temp/bigEncrypted.dat")
End Sub

VB.NET HTTP Download with percent-done progress monitoring

Here is an example:

    Dim WithEvents http As Chilkat.Http

    Private Sub http_OnPercentDone(ByVal sender As Object, ByVal args As Chilkat.PercentDoneEventArgs) Handles http.OnPercentDone
        ProgressBar1.Value = args.PercentDone
    End Sub

    Private Sub HttpDownloadTest()

        http = New Chilkat.Http()

        Dim success As Boolean

        '  Any string unlocks the component for the 1st 30-days.
        success = http.UnlockComponent("Anything for 30-day trial")
        If (success <> True) Then
            Exit Sub
        End If

        ' Enable event callbacks...
        http.EnableEvents = True

        '  Download the Python language install.
        '  Note: This URL may have changed since this example was created.
        success = http.Download("http://www.python.org/ftp/python/2.5/python-2.5.msi", "python-2.5.msi")
        If (success <> True) Then
            MsgBox("Python Download Complete!")
        End If

        http = Nothing

    End Sub

Can Ftp2.SyncLocalTree be progress monitored?

The FTP2 component’s SyncLocalTree method downloads an entire directory tree from an FTP server to the local filesystem. There are several modes of operation:

mode=0: Download all files
mode=1: Download all files that do not exist on the local filesystem.
mode=2: Download newer or non-existant files.
mode=3: Download only newer files. If a file does not already exist on the local filesystem, it is not downloaded from the server.

It is possible to monitor activity via the AbortCheck event. The AbortCheck event is called periodically according to the HeartbeatMs property setting. The AbortCheck callback method has one argument: an output-only “abort” flag. If set to true (non-zero), the FTP2 component will abort the SyncLocalTree.

It is not possible to monitor a percentage completion (i.e. 0% to 100%). The reason is that it is impossible to know the full extent of the remote directory tree and files to be downloaded. There is nothing in the FTP protocol that allows a client to ask the server to “give me the sum of the sizes of all files in a directory tree”. The SyncLocalTree works by traversing the directory tree through a series of “change directory” commands, downloading files in each directory found, etc.