Provides advanced options for the QuickSynchronize and QuickSynchronizeAsync methods.

      Syntax

      public sealed class QuickSyncOptions : ICloneable

      Examples

      FTP Examples

      The following example demonstrates how to handle the Progress event to report the current progress state in a Mirror operation and skip a file.

      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      static void Main()
      {
          Ftp client = new Ftp();
      
          // Connect to the FTP server. 
          client.Connect("192.168.126.128", 21);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Register event handler. 
          client.Progress += client_Progress;
      
          // Create a new instance of the MirrorOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different modification date time or different file size. 
          // Files with the same size and modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer;
          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
              );
      
      
      
          // Synchronize files with different attributes and different file size. 
          // Files with the same attributes or size will not be synchronized. 
          opt.Comparer = FileComparers.FileAttributesComparer | FileComparers.FileSizeComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "my remote dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means remote directory "my remote dir" will be identical to the local dir "c:\test". 
              opt
              );
      
      
      
          // Synchronize files that have different contents. 
          // Files with the same content will not be synchronized. 
          opt.Comparer = FileComparers.FileContentComparer;
          opt.Recursive = true;
      
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "my remote dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means remote directory "my remote dir" will be identical to the local dir "c:\test". 
              opt
              );
      
          // Do something here 
          // ... 
       
          client.Disconnect();
      }
      
      static void client_Progress(object sender, FileSystemProgressEventArgs e)
      {
          switch (e.State)
          {
              // For files 
              case TransferState.DeletingFile:
              case TransferState.StartUploadingFile:
              case TransferState.StartDownloadingFile:
                  Console.WriteLine(string.Format("Sync - Applying change on file '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my file")
                      e.Skip = true; // we skip the changes. 
                  break;
      
              case TransferState.FileDeleted:
              case TransferState.FileUploaded:
              case TransferState.FileDownloaded:
                  Console.WriteLine(string.Format("Sync - change applied on file '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  break;
      
              // For directory 
              case TransferState.DeletingDirectory:
              case TransferState.CopyingDirectory:
              case TransferState.CreatingDirectory:
                  Console.WriteLine(string.Format("Sync - Applying change on directory '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my folder")
                      e.Skip = true; // we skip the changes. 
                  break;
      
              case TransferState.DirectoryDeleted:
              case TransferState.DirectoryCreated:
                  Console.WriteLine(string.Format("Sync - change applied on directory '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my folder")
                      e.Skip = true; // we skip the changes. 
                  break;
          }
      }

      SFTP Examples

      Shows how to use file comparer classes and synchronize files and folders.

      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      void SynchronizeFilesDirs()
      {
          Sftp client = new Sftp();
      
          // Connect to the SFTP server. 
          client.Connect("192.168.126.128", 22);
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          // Register event handler. 
          client.Progress += client_Progress;
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different modification date time or different file size. 
          // Files with the same size and modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer;
          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
              );
      
      
      
          // Synchronize files with different attributes and different file size. 
          // Files with the same attributes or size will not be synchronized. 
          opt.Comparer = FileComparers.FileAttributesComparer | FileComparers.FileSizeComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "my remote dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means remote directory "my remote dir" will be identical to the local dir "c:\test". 
              opt
              );
      
      
      
          // Synchronize files that have different contents. 
          // Files with the same content will not be synchronized. 
          opt.Comparer = FileComparers.FileContentComparer;
          opt.Recursive = true;
      
      
          // Synchronize folders. 
          client.QuickSynchronize(
              "my remote dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means remote directory "my remote dir" will be identical to the local dir "c:\test". 
              opt
              );
      
          // Do something here 
          // ... 
       
          client.Disconnect();
      }
      
      void client_Progress(object sender, FileSystemProgressEventArgs e)
      {
          switch (e.State)
          {
              // For files 
              case TransferState.DeletingFile:
              case TransferState.StartUploadingFile:
              case TransferState.StartDownloadingFile:
                  Console.WriteLine(string.Format("Sync - Applying change on file '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my file")
                      e.Skip = true; // we skip the changes. 
                  break;
      
              case TransferState.FileDeleted:
              case TransferState.FileUploaded:
              case TransferState.FileDownloaded:
                  Console.WriteLine(string.Format("Sync - change applied on file '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  break;
      
              // For directory 
              case TransferState.DeletingDirectory:
              case TransferState.CopyingDirectory:
              case TransferState.CreatingDirectory:
                  Console.WriteLine(string.Format("Sync - Applying change on directory '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my folder")
                      e.Skip = true; // we skip the changes. 
                  break;
      
              case TransferState.DirectoryDeleted:
              case TransferState.DirectoryCreated:
                  Console.WriteLine(string.Format("Sync - change applied on directory '{0}', change type: {1}", e.SourceFileInfo.Name, e.State));
                  if (e.SourceFileInfo.Name == "my folder")
                      e.Skip = true; // we skip the changes. 
                  break;
          }
      }

      ZIP Examples

      Shows how to use file comparer classes and synchronize files and folders.

      using ComponentPro.IO;
      using ComponentPro.Compression;
      
      ...
      
      void SynchronizeFilesDirs()
      {
          Zip zip = new Zip();
      
          // Open an existing archive. 
          zip.Open("test.zip", System.IO.FileMode.Open);
      
          zip.Progress += zip_Progress;
      
          // Create a new instance of the QuickSyncOptions class. 
          QuickSyncOptions opt = new QuickSyncOptions();
      
          // Set synchronization's settings 
          // Synchronize files with different modification date time or different file size. 
          // Files with the same size and modification date time will not be synchronized. 
          opt.Comparer = FileComparers.FileLastWriteTimeComparer & FileComparers.FileSizeComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          zip.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 with different attributes and different file size. 
          // Files with the same attributes or size will not be synchronized. 
          opt.Comparer = FileComparers.FileAttributesComparer | FileComparers.FileSizeComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          zip.QuickSynchronize(
              "/my dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means directory within the archive named "/my dir" will be identical to the local dir "c:\test". 
              opt
              );
      
      
      
          // Synchronize files that have different contents. 
          // Files with the same content will not be synchronized. 
          opt.Comparer = FileComparers.FileContentComparer;
          opt.Recursive = true;
      
          // Synchronize folders. 
          zip.QuickSynchronize(
              "my remote dir", // Source directory path. 
              "c:\\test", // Destination directory path.                 
              false, // Destination directory is master. It means remote directory "my remote dir" will be identical to the local dir "c:\test". 
              opt
              );
      
          // Do something here 
          // ... 
       
          zip.Close();
      }
      
      private void zip_Progress(object sender, FileSystemProgressEventArgs e)
      {
          // Skip deleting file with .doc extension. If you do not want to delete any files, always set e.Skip to true. 
          if (e.State == TransferState.DeletingFile && e.SourcePath.EndsWith(".doc"))
          {
              // Skip. 
              e.Skip = true;
          }
      }

      Inheritance Hierarchy

         ComponentPro.IO.ComponentPro.IO.QuickSyncOptions

      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