ComponentPro UltimateSftp

      FileComparisonResult Enumeration

      See AlsoMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      Represents the file comparison result. This result enum is used for the property ComparisonResult.

      Syntax

      public enum FileComparisonResult

      Members

      NameDescription
      EqualSource file and destination file are equal.
      NotEqualSource file and destination file are different.
      ResumableDestination file is not completely copied. This is used for FileContentComparer and FileSizeComparer.
      Top

      Examples

      FTP Examples

      Shows how to use a custom file comparer class when synchronizing files and folders.

      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      class CustomComparer : FileComparer
      {
          /// <summary> 
          /// Compares the target files to the master file and returns values indicating whether the target files are equal to the master. 
          /// </summary> 
          /// <param name="masterFile">The master file.</param> 
          /// <param name="targetFiles">The target files to compare.</param> 
          /// <returns><see cref="FileComparisonResult"/>.Equal if the first file is equal to second one.</returns> 
          public override FileComparisonResult[] Compare(FileInfoBase masterFile, FileInfoBase[] targetFiles)
          {
              FileComparisonResult[] results = new FileComparisonResult[targetFiles.Length];
      
              for (int i = 0; i < targetFiles.Length; i++)
              {
                  FileInfoBase targetFile = targetFiles[i];
      
                  // Two files are equal if their name, size, and last write time matched.                 
                  bool equal = string.Compare(masterFile.Name, targetFile.Name, true) == 0 &&
                               masterFile.LastWriteTime == targetFile.LastWriteTime &&
                               masterFile.Length == targetFile.Length;
      
                  results[i] = equal ? FileComparisonResult.Equal : FileComparisonResult.NotEqual;
              }
      
              return results;
          }
      }
      
      static void Main()
      {
          Ftp client = new Ftp();
      
          // Connect to the FTP server. 
          client.Connect("demo.componentpro.com");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the MirrorOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different name, modification date time, or file size. 
          opt.Comparer = new CustomComparer();
          opt.Recursive = true;
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true, // Source directory is master. It means "c:\test" will be identical to the remote dir. 
              opt
              );
      
          // Do something here 
          // ... 
       
          client.Disconnect();
      }

      SFTP Examples

      Shows how to use a custom file comparer class when synchronizing files and folders.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      class CustomComparer : FileComparer
      {
          /// <summary> 
          /// Compares the target files to the master file and returns values indicating whether the target files are equal to the master. 
          /// </summary> 
          /// <param name="masterFile">The master file.</param> 
          /// <param name="targetFiles">The target files to compare.</param> 
          /// <returns><see cref="FileComparisonResult"/>.Equal if the first file is equal to second one.</returns> 
          public override FileComparisonResult[] Compare(FileInfoBase masterFile, FileInfoBase[] targetFiles)
          {
              FileComparisonResult[] results = new FileComparisonResult[targetFiles.Length];
      
              for (int i = 0; i < targetFiles.Length; i++)
              {
                  FileInfoBase targetFile = targetFiles[i];
      
                  // Two files are equal if their name, size, and last write time matched.                 
                  bool equal = string.Compare(masterFile.Name, targetFile.Name, true) == 0 &&
                               masterFile.LastWriteTime == targetFile.LastWriteTime &&
                               masterFile.Length == targetFile.Length;
      
                  results[i] = equal ? FileComparisonResult.Equal : FileComparisonResult.NotEqual;
              }
      
              return results;
          }
      }
      
      void Synchronize_CustomComparer()
      {
          Sftp client = new Sftp();
      
          // Connect to the SFTP server. 
          client.Connect("demo.componentpro.com");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different name, modification date time, or file size. 
          opt.Comparer = new CustomComparer();
          opt.Recursive = true;
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true, // Source directory is master. It means "c:\test" will be identical to the remote dir. 
              opt
              );
      
          // Do something here 
          // ... 
       
          client.Disconnect();
      }

      ZIP Examples

      Shows how to use a custom file comparer class when synchronizing files and folders.

      using ComponentPro.IO;
      using ComponentPro.Compression;
      
      ...
      
      class CustomComparer : FileComparer
      {
          /// <summary> 
          /// Compares the target files to the master file and returns values indicating whether the target files are equal to the master. 
          /// </summary> 
          /// <param name="masterFile">The master file.</param> 
          /// <param name="targetFiles">The target files to compare.</param> 
          /// <returns><see cref="FileComparisonResult"/>.Equal if the first file is equal to second one.</returns> 
          public override FileComparisonResult[] Compare(FileInfoBase masterFile, FileInfoBase[] targetFiles)
          {
              FileComparisonResult[] results = new FileComparisonResult[targetFiles.Length];
      
              for (int i = 0; i < targetFiles.Length; i++)
              {
                  FileInfoBase targetFile = targetFiles[i];
      
                  // Two files are equal if their name, size, and last write time matched.                 
                  bool equal = string.Compare(masterFile.Name, targetFile.Name, true) == 0 &&
                               masterFile.LastWriteTime == targetFile.LastWriteTime &&
                               masterFile.Length == targetFile.Length;
      
                  results[i] = equal ? FileComparisonResult.Equal : FileComparisonResult.NotEqual;
              }
      
              return results;
          }
      }
      
      void Synchronize_CustomComparer()
      {
          Zip zip = new Zip();
      
          // Open an existing archive. 
          zip.Open("test.zip", System.IO.FileMode.Open);
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different name, modification date time, or file size. 
          opt.Comparer = new CustomComparer();
          opt.Recursive = true;
      
          // Synchronize folders. 
          zip.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true, // Source directory is master. It means "c:\test" will be identical to the specified directory within the archive. 
              opt
              );
      
          // Do something here 
          // ... 
       
          zip.Close();
      }

      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)

      Portable Class Library for Windows Phone 8.1 and Windows 8.1 Store AppsPortable Class Library for Windows Phone 8.1 and Windows 8.1 Store Apps

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.WinPcl (in ComponentPro.FileSystem.WinPcl.dll)

      Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.Uwp (in ComponentPro.FileSystem.Uwp.dll)

      Xamarin AndroidXamarin Android

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

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.FileSystem.Mac (in ComponentPro.FileSystem.Mac.dll)

      Xamarin iOSXamarin iOS

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

      See Also