ComponentPro UltimateZip

      FileChecksumComparer Class

      See AlsoMembersMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      Represents file checksum comparer.

      Syntax

      public class FileChecksumComparer : IoFileComparer

      Examples

      FTP Examples

      Shows how to use FileComparers.FileChecksumComparer for synchronizing a local folder with a remote folder.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance.
      Ftp client = new Ftp();
      
      // Connect to the FTP server.
      client.Connect("myserver");
      
      // Authenticate.
      client.Authenticate("userName", "password");
      
      // Create a new instance of the MirrorOptions class.
      QuickSyncOptions opt = new QuickSyncOptions();
      
      // Set synchronization's settings 
      // Synchronize files that are different in checksum. 
      // Files with the same SHA1 computed checksum will not be synchronized.
      opt.Comparer = FileComparers.FileSha1ChecksumComparer;
      opt.Recursive = true;
      
      // Synchronize folders.
      client.QuickSynchronize(
          "", // Source directory path within the archive. "" indicates the current remote directory on the server. 
          "c:\\test", // Destination directory path.                 
          true, // Source directory is master. It means "c:\test" will be identical to the current remote directory. 
          opt
          );
      
      // Synchronize files that are different in contents.
      opt.Comparer = FileComparers.FileSha1ChecksumComparer;
      opt.Recursive = true;
      
      // Synchronize folders.
      client.QuickSynchronize(
          "", // Source directory path within the archive. "" indicates the current remote directory on the server. 
          "c:\\test2", // Destination directory path.                 
          true, // Source directory is master. It means "c:\test2" will be identical to the current remote directory. 
          opt
          );
      
      // That comparer can also be used in Upload and Download operations.
      TransferOptions transferOptions = new TransferOptions();
      // Files with the same checksum will not be downloaded.
      transferOptions.Comparer = FileComparers.FileSha1ChecksumComparer;
      transferOptions.FileOverwriteMode = FileOverwriteMode.CustomCompare;
      // Download .txt files from the current remote directory. Only files with different checksum will be downloaded.
      client.Download("*.txt", "C:\\temp", transferOptions);
      
      // Close the connection.
      client.Disconnect();

      SFTP Examples

      Shows how to use FileComparers.FileChecksumComparer for synchronizing a local folder with a remote folder.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance.
      Sftp client = new Sftp();
      
      // Connect to the SFTP server.
      client.Connect("myserver");
      
      // Authenticate.
      client.Authenticate("userName", "password");
      
      // Create a new instance of the MirrorOptions class.
      QuickSyncOptions opt = new QuickSyncOptions();
      
      // Set synchronization's settings 
      // Synchronize files that are different in checksum. 
      // Files with the same SHA1 computed checksum will not be synchronized.
      opt.Comparer = FileComparers.FileSha1ChecksumComparer;
      opt.Recursive = true;
      
      // Synchronize folders.
      client.QuickSynchronize(
          "", // Source directory path within the archive. "" indicates the current remote directory on the server. 
          "c:\\test", // Destination directory path.                 
          true, // Source directory is master. It means "c:\test" will be identical to the current remote directory. 
          opt
          );
      
      // Synchronize files that are different in contents.
      opt.Comparer = FileComparers.FileSha1ChecksumComparer;
      opt.Recursive = true;
      
      // Synchronize folders.
      client.QuickSynchronize(
          "", // Source directory path within the archive. "" indicates the current remote directory on the server. 
          "c:\\test2", // Destination directory path.                 
          true, // Source directory is master. It means "c:\test2" will be identical to the current remote directory. 
          opt
          );
      
      // That comparer can also be used in Upload and Download operations.
      TransferOptions transferOptions = new TransferOptions();
      // Files with the same checksum will not be downloaded.
      transferOptions.Comparer = FileComparers.FileSha1ChecksumComparer;
      transferOptions.FileOverwriteMode = FileOverwriteMode.CustomCompare;
      // Download .txt files from the current remote directory. Only files with different checksum will be downloaded.
      client.Download("*.txt", "C:\\temp", transferOptions);
      
      // Close the connection.
      client.Disconnect();

      ZIP Examples

      Shows how to use FileComparers.FileChecksumComparer for synchronizing a local folder with a remote folder.

      using ComponentPro.Compression;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance. 
      using (Zip arc = new Zip())
      {
          arc.Open("myzip.zip");
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files that are different in checksum. 
          // Files with the same SHA1 computed checksum will not be synchronized. 
          opt.Comparer = FileComparers.FileSha1ChecksumComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          arc.QuickSynchronize(
              "", // Source directory path within the archive. "" indicates the current directory within the archive. 
              "c:\\test", // Destination directory path.                 
              true, // Source directory is master. It means "c:\test" will be identical to the directory within the archive. 
              opt
              );
      
          // Synchronize files that are different in contents. 
          opt.Comparer = FileComparers.FileSha1ChecksumComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          arc.QuickSynchronize(
              "", // Source directory path within the archive. "" indicates the current directory within the archive. 
              "c:\\test2", // Destination directory path.                 
              true, // Source directory is master. It means "c:\test2" will be identical to the directory within the archive. 
              opt
              );
      
          // That comparer can also be used in UploadFiles and DownloadFiles operations. 
          TransferOptions transferOptions = new TransferOptions();
          // Files with the same checksum will not be extracted. 
          transferOptions.Comparer = FileComparers.FileSha1ChecksumComparer;
          transferOptions.FileOverwriteMode = FileOverwriteMode.CustomCompare;
          // Extract .txt files from the current archive directory. Only files with different checksum will be extracted. 
          arc.ExtractFiles("*.txt", "C:\\temp", transferOptions);
      }

      Inheritance Hierarchy

               ComponentPro.IO.ComponentPro.IO.FileChecksumComparer

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.FileSystem.CF (in ComponentPro.FileSystem.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.FileSystem (in ComponentPro.FileSystem.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.FileSystem.Android (in ComponentPro.FileSystem.Android.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.FileSystem.iOS (in ComponentPro.FileSystem.iOS.dll)

      See Also