public class OrFileComparer : FileComparer
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 ); }
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 ); }
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 ); }