Xceed .NET Libraries Documentation
Synchronizing folders

Welcome to Xceed .NET, .NET Standard and Xamarin Libraries! > Task-Based Help > Synchronizing files and folders > Synchronizing folders

This topic demonstrates how to synchronize disk folders.

Basic steps

To synchronizes folders, the following steps must be performed:

Demonstration

The following example demonstrates how to synchronize disk folders. Note that when synchronizing only folders, files within the folders are synchronized to the most recent version of the correspondingly named file.

VB.NET Copy Code

Imports Xceed.FileSystem
Imports Xceed.Synchronize

Try
  Dim folder1 As AbstractFolder = New DiskFolder("D:\temp\folder1")
  Dim folder2 As AbstractFolder = New DiskFolder("D:\temp\folder2")
  Dim folder3 As AbstractFolder = New DiskFolder("D:\temp\folder3")
  Dim syncOptions As New SynchronizationOptions()

  syncOptions.UseMetaData = False 'By default, this value is true.

  Try
    Synchronizer.EasySynchronize(folder1, folder2, folder3, syncOptions)
  Catch eSynch As Exception
    Console.WriteLine("Synch error: {0}", eSynch.ToString())
  End Try
Catch ePrepSynch As Exception
  Console.WriteLine("Prep-synch error: {0}", ePrepSynch.ToString())
End Try

C# Copy Code

using Xceed.FileSystem;
using Xceed.Synchronize;

try
{
  AbstractFolder folder1 = new DiskFolder(@"D:\temp\folder1");
  AbstractFolder folder2 = new DiskFolder(@"D:\temp\folder2");
  AbstractFolder folder3 = new DiskFolder(@"D:\temp\folder3");

  SynchronizationOptions syncOptions = new SynchronizationOptions();
  syncOptions.UseMetaData = false; //By default, this value is true.

  try
  {
    Synchronizer.EasySynchronize(folder1, folder2, folder3);  }
  catch (Exception eSynch)
  {
    Console.WriteLine("Synch error: {0}", eSynch.ToString());
  }
}
catch (Exception ePrepSynch)
{
  Console.WriteLine("Prep-synch error: {0}", ePrepSynch.ToString());
}

Things you should consider

Here are the main questions you should ask yourself when synchronizing files: