ComponentPro UltimateFtp

      Chunk file download

      Language Filter: AllSend comments on this topic to ComponentPro

      Ultimate FTP allows you to break a large file into multiple ones of a smaller set size so that the file can be downloaded faster. The following code snippet illustrates how to download many small pieces of a large file simultaneously.

      using System;
      using System.Collections.Generic;
      using System.Text;
      using System.IO;
      using System.Text.RegularExpressions;
      using ComponentPro.IO;
      using ComponentPro.Net;
      using System.Threading;
      static void Main()
          // Create a new class instance. 
          using (Ftp client = new Ftp())
              // Connect to the FTP server. 
              // Authenticate. 
              client.Authenticate("userName", "password");
              // ... 
              client.Progress += ClientOnProgress;
              client.MultiPartDownload("/folder/remotefile.dat", "c:\\localfile.dat", 5, DownloadErrorHandler, DownloadCompletedHandler);
              // ... 
      static void DownloadErrorHandler(MultiPartDownloadErrorEventArgs e)
          Console.WriteLine("Error: " + e.Error.Message);
          Console.Write("Do you want to retry (y/n)?");
          int c = Console.Read();
          if (c == 'y')
              e.Retry = true;
      static void DownloadCompletedHandler(MultiPartDownloadResult result)
          Console.WriteLine("Success: " + result.Success);
      private static void ClientOnProgress(object sender, FileSystemProgressEventArgs e)
          Console.WriteLine("Progression Percentage: " + e.Percentage);