• Licensing and How to Order
  • Installation Instruction
  • Encrypting and Decrypting
  • Zipping Files & Folders
  • Unzipping Files & Folders
  • Listing Files & Folders
  • Deleting, Renaming and Moving Files & Folders
  • Synchronizing files and directories
  • Quick Synchronizing and Updating Archive
  • Testing Files
  • Working with Transaction System
  • Spanning or Splitting Archive
  • Creating Self-Extracting Archive
  • Working with RealTimeZip
  • Working with Tar
  • Working with Tgz
  • Working with GZip
  • Transferring/Receiving Files & Folders to/from another File System (SFTP, FTP, SCP, etc.)
  • Handling Events
      ComponentPro UltimateZip

      Displaying progress while transferring data

      Language Filter: AllSend comments on this topic to ComponentPro

      When the file to transfer is big and your application may take time to transfer, you may wish to show the progress of the transfer to the user. The UltimateZip component provides progress notification through the Progress event. The Progress event is raised periodically while data transfer is in progress, making accessible necessary data to display progress information, such as the size of the file and the number of bytes transferred.

      The following steps show you how to use the Progress event to show progress information while transferring a file:

      using System;
      using ComponentPro.IO;
      using ComponentPro.Compression;
      private Zip _zip;
      public void DoUpload()
          // Create a new instance. 
          Zip zip = new Zip();
          _zip = zip;
          // Create a new archive. 
          // ... 
          zip.TransferConfirm += zip_TransferConfirm;
          zip.Progress += zip_Progress;
              TransferOptions opt = new TransferOptions("*.*", FileOverwriteMode.Confirm);
              // Add all directories, subdirectories, and files in local folder 'c:\myfolder' to remote folder '/myfolder'. 
              zip.AddFiles("c:\\myfolder", "/myfolder", opt);
          catch (Exception exc)
              Console.WriteLine("Error: " + exc.Message);
          // ... 
          // Close. 
      /// <summary> 
      /// This method is raised when user clicks on 'Cancel' button on the form. 
      /// </summary> 
      protected void btnCancel_Click(object sender, EventArgs e)
          // Cancel the upload operation when user clicks on the button. 
      void zip_Progress(object sender, ComponentPro.IO.FileSystemProgressEventArgs e)
          // Show progress info. 
          Console.WriteLine("Current File: %{0} completed", e.Percentage);
          Console.WriteLine("Total: %{0} completed", e.TotalPercentage);
          switch (e.State)
              case TransferState.StartStoringFile:
                  if (e.SourcePath.EndsWith(".exe"))
                      // Skip all .exe files 
                      e.Skip = true;
                  else if (e.SourcePath.StartsWith(@"C:\MyFolder"))
                      // Change the source file path if it starts with "C:\MyFolder" 
                      e.SourcePath = e.SourcePath.Replace(@"C:\MyFolder", @"C:\MySecondFolder");
      void zip_TransferConfirm(object sender, ComponentPro.IO.TransferConfirmEventArgs e)
          if (e.Exception != null)
              Console.WriteLine("Error: " + e.Exception.Message);
          if (e.ConfirmReason == TransferConfirmReason.FileAlreadyExists)
              // Skip the existing file. 
              e.NextAction = TransferConfirmNextActions.Skip;
          Console.Write("Do you want to (r)etry or (s)kip?");
          string key = Console.ReadLine();
          if (key == "r")
              e.NextAction = TransferConfirmNextActions.Retry;
          else if (key == "s")
              e.NextAction = TransferConfirmNextActions.Skip;
              // Cancel the operation. 
              e.NextAction = TransferConfirmNextActions.Cancel;