Represents a logical OR operation on a set of FileComparer object.

      Syntax

      public class OrFileComparer : FileComparer

      Examples

      FTP Examples

      The OrFileComparer class can be used for the Upload and Download operations. The following example code demonstrates how to use the OrFileComparer class to create a logical OR comparer from two file comparers.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      using (Ftp client = new Ftp())
      {
          // Connect to the FTP server. 
          client.Connect(MyFtpServer, MyFtpPort);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the TransferOptions. 
          TransferOptions opt = new TransferOptions();
      
          // Set transfer options 
          // Upload files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be uploaded. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer | FileComparers.FileSizeComparer; // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.FileOverwriteMode = FileOverwriteMode.CustomCompare; // Indicates that the above Comparer is used. 
       
          // Upload files and subdirectories in "C:\test" to the current remote directory. 
          client.Upload(
              "c:\\test", // Source directory path 
              "", // Destination directory path - "" means current directory 
              opt
              );
      }

      The following example code demonstrates how to use the OrFileComparer class to create a logical AND comparer from two file comparers in a Mirror operation.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      using (Ftp client = new Ftp())
      {
          // Connect to the FTP server. 
          client.Connect(MyFtpServer, MyFtpPort);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the MirrorOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set mirror settings 
          // Mirror files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer; // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.Recursive = true;
      
          // Mirror folders. 
          client.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true,
              // Source directory is master. It means contents of "c:\test" will be identical to the remote dir's. 
              opt
              );
      }

      SFTP Examples

      The OrFileComparer class can be used for the Upload and Download operations. The following example code demonstrates how to use the OrFileComparer class to create a logical OR comparer from two file comparers.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      using (Sftp client = new Sftp())
      {
          // Connect to the SFTP server. 
          client.Connect(MySftpServer, MySftpPort);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the TransferOptions. 
          TransferOptions opt = new TransferOptions();
      
          // Set transfer options 
          // Upload files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be uploaded. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer | FileComparers.FileSizeComparer; // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.FileOverwriteMode = FileOverwriteMode.CustomCompare; // Indicates that the above Comparer is used. 
       
          // Upload files and subdirectories in "C:\test" to the current remote directory. 
          client.Upload(
              "c:\\test", // Source directory path 
              "", // Destination directory path - "" means current directory 
              opt
              );
      }

      The following example code demonstrates how to use the OrFileComparer class to create a logical AND comparer from two file comparers in a Mirror operation.

      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      using (Sftp client = new Sftp())
      {
          // Connect to the SFTP server. 
          client.Connect(MySftpServer, MySftpPort);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Create a new instance of the MirrorOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set mirror settings 
          // Mirror files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer; // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.Recursive = true;
      
          // Mirror folders. 
          client.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true,
              // Source directory is master. It means contents of "c:\test" will be identical to the remote dir's. 
              opt
              );
      }

      ZIP Examples

      The OrFileComparer class can be used for the UploadFiles and ExtractFiles operations. The following example code demonstrates how to use the OrFileComparer class to create a logical OR comparer from two file comparers.

      using ComponentPro.Compression;
      using ComponentPro.IO;
      
      ...
      
      using (Zip arc = new Zip())
      {
          // Create a new ZIP file. 
          arc.Create("myzip.zip");
      
          // Create a new instance of the TransferOptions. 
          TransferOptions opt = new TransferOptions();
      
          // Set transfer options 
          // Upload files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be uploaded. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer | FileComparers.FileSizeComparer;  // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.FileOverwriteMode = FileOverwriteMode.CustomCompare; // Indicates that the above Comparer is used. 
       
          // Upload files and subdirectories in "C:\test" to the current archiver directory. 
          arc.AddFiles(
              "c:\\test", // Source directory path 
              "", // Destination directory path - "" means current directory 
              opt
              );
      }

      The following example code demonstrates how to use the OrFileComparer class to create a logical AND comparer from two file comparers in a Mirror operation.

      using ComponentPro.Compression;
      using ComponentPro.IO;
      
      ...
      
      using (Zip arc = new Zip())
      {
          // Open an existing ZIP file. 
          arc.Open("myzip.zip");
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set mirror settings 
          // Mirror files with different modification date time and different file size. 
          // Files with the same size OR modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer; // Equivalent to 'new OrFileComparer(FileComparers.FileLastWriteTimeComparer, FileComparers.FileSizeComparer)' 
          opt.Recursive = true;
      
          // Mirror folders. 
          arc.QuickSynchronize(
              "", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              true, // Source directory is master. It means contents of "c:\test" will be identical to the remote dir's. 
              opt
              );
      }

      Inheritance Hierarchy

            ComponentPro.IO.ComponentPro.IO.OrFileComparer

      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