Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

September 24, 2007

FTP Upload/Download in C# Background Threads with Progress Monitoring and Abort

This blog post provides a C# example in Visual Studio 2005 that can do FTP uploads and downloads in a background thread, and can monitor the progress in a progress bar as well as abort the operation while in progress.

Here is a screenshot:
FTP BackgroundWorker Example

The VS2005 project files may be downloaded from here:

Visual Studio project on GitHub

Important: We specifically excluded the ChilkatDotNet2.dll from this download. After opening the project, remove the existing reference to ChilkatDotNet2.dll and re-add it using the ChilkatDotNet2.dll you downloaded from the Chilkat web site.

There are two types of activity monitoring: heartbeat event callbacks, and percentage completion callbacks. Heartbeat callbacks are common to all Chilkat components with events. There is a HeartbeatMs property that controls the frequency of AbortCheck events. The component will fire AbortCheck events during any method call (Connect, ChangeRemoteDir, GetFile, PutFile, Syst, etc.) Any operation can be aborted by setting the Abort flag in the AbortCheckEventArgs argument.

Percentage completion events are fired for operations where it makes sense (i.e. in cases where it is possible to know in advance the amount of work yet to be done). Methods such as Connect and ChangeRemoteDir will not fire percentage-completion events. Methods such as GetFile and PutFile (of course) fire PercentDone events.

This example shows how to monitor and abort tasks that happen both in the foreground thread and a background thread. It uses the .NET BackgroundWorker helper class, which is crucial in being able to update Form elements such as a progress bar.

The example’s source code is extensively documented. If you have any questions about how it works, please send email to

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.