• 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

      Handling Exceptions

      Language Filter: AllSend comments on this topic to ComponentPro

      Introduction to exceptions in UltimateZip

      The exceptions that can be thrown by UltimateZip are handled in the same manner as regular runtime exception using Try/Catch blocks.

      The following table provides a list of the custom exceptions that can be thrown when an error occurs:

       

      Exception Description
      ZipException Exception that is thrown when an error occurs while processing Zip file.
      FileSystemException Exception that is thrown when an error occurs while adding or extracting files and directories.


      Sample

      Example below shows how to handle these exceptions:

      using ComponentPro.Compression;
      using System;
      
      ...
      
      try
      {
          // Create a new instance. 
          Zip zip = new Zip();
          // Create a new zip file. 
          zip.Create("test.zip");
          // Set password 
          zip.EncryptionAlgorithm = EncryptionAlgorithm.PkzipClassic;
          zip.Password = "password";
      
          // Add all files and subdirectories from 'c:\test' to the archive. 
          zip.AddFiles(@"c:\test");
      
          // Add all files and subdirectories from 'c:\my folder' to the archive. 
          zip.AddFiles(@"c:\my folder", "");
      
          // Add all files and subdirectories from 'c:\my folder' to '22' folder within the archive. 
          zip.AddFiles(@"c:\my folder2", "22");
      
          // Add all .dat files from 'c:\my folder' to '22' folder within the archive. 
          zip.AddFiles(@"c:\my folder2", "22", "*.dat");
      
          // Close the zip file. 
          zip.Close();
      }
      catch (ZipException exc)
      {
          Console.WriteLine("Error: " + exc.Message);
      }