我在C#.NET中使用Microsoft SyncFramework for Filesyncronization
同步效果很好但是当我在源中更新文件名时,将在目标路径中创建一个新文件。此外,当我更改目标中的文件时,它不会从源路径更新,或者如果我删除了源路径中的文件,则不会删除目标中的文件。
有人可以帮助我吗?
这是我的代码:
var sourceId = new SyncId(Guid.NewGuid());
var destId = new SyncId(Guid.NewGuid());
FileSyncOptions options = FileSyncOptions.ExplicitDetectChanges
| FileSyncOptions.RecycleDeletedFiles
| FileSyncOptions.RecyclePreviousFileOnUpdates
| FileSyncOptions.RecycleConflictLoserFiles;
FileSyncScopeFilter filter = new FileSyncScopeFilter();
filter.FileNameExcludes.Add("*.metadata");
var sourceProvider = new FileSyncProvider(
sourceId.GetGuidId(), _sourcePath, filter, options);
var destinationProvider = new FileSyncProvider(
destId.GetGuidId(), _destinationPath, filter, options);
sourceProvider.Configuration.ConflictResolutionPolicy =
ConflictResolutionPolicy.SourceWins;
destinationProvider.Configuration.ConflictResolutionPolicy =
ConflictResolutionPolicy.SourceWins;
sourceProvider.DetectChanges();
destinationProvider.DetectChanges();
var agent = new SyncOrchestrator();
agent.LocalProvider = sourceProvider;
agent.RemoteProvider = destinationProvider;
agent.Direction = SyncDirectionOrder.Upload;
agent.Synchronize();