To abort a file transfer that is still in progress, you can either call the Cancel method or close the connection by calling the Disconnect or DisconnectAsync method.
The following code snippet shows how to use it.
using System; using ComponentPro.IO; using ComponentPro.Net; ... private static void Main() { // Create a new Ftp instance. Ftp client = new Ftp(); // Connect to the FTP server. client.Connect("demo.componentpro.com"); // Authenticate. client.Authenticate("test", "test"); try { // Register an event handler. client.Progress += client_Progress; // Upload file "c:\test.zip". client.UploadFile("c:\\test.zip", "test.zip"); } catch (FtpException exc) { Console.WriteLine("Exception: " + exc.Message); } // Disconnect. client.Disconnect(); } private static void client_Progress(object sender, FileSystemProgressEventArgs e) { // Abort the uploading operation if the bytes transferred is greater than or equal to 500Kb. if (e.State == TransferState.Uploading && e.BytesTransferred >= 1024*500) { ((Ftp) sender).Cancel(); } }