I need to do basic one way file synchronization from local to remote server. I tried to use Microsoft Sync Framework, and it works just fine. However, I will need two features which I can not get now:
- If file has been deleted on the destination, next synchronization should recreate it from the source
- If file has been changed on the destination, next synchronization should replace it from the source
Is it possible to get that by using some options in SyncOrchestrator.Synchronize() function ?
Existing code is based on MSDN article:
public static void SyncFileSystemReplicaOneWay(string sourcePath, string destinationPath)
{
FileSyncProvider sourceProvider = null;
FileSyncProvider destinationProvider = null;
try
{
sourceProvider = new FileSyncProvider(sourcePath);
destinationProvider = new FileSyncProvider(destinationPath);
var agent = new SyncOrchestrator();
agent.LocalProvider = sourceProvider;
agent.RemoteProvider = destinationProvider;
agent.Direction = SyncDirectionOrder.Upload;
var stats = agent.Synchronize();
}
finally
{
if (sourceProvider != null) sourceProvider.Dispose();
if (destinationProvider != null) destinationProvider.Dispose();
}
}