Wednesday, February 06, 2013 8:55 PM
I would like to use the FileSyncProvider to analyze a baseline of a folder and all of its subdirectories, and files, then compare the baseline to the current state of the folder. I don't want a folder-to-folder sync. I want to dive into the calls that get up to the point of DetectedChanges, and operate on the output of that, to chain it to a much more sophisticated syncrhonization task.
All changes should be detected when "ChangeBatch" is later called. I have successfully nearly achieved the results with the following procedure, but ChangeKind.Deleted will not disclose the FilePath of the deleted file (so it blows up on IFileDataRetriever cast). Another problem is that new files are posted as Update to a directory as a ChangeKind, so they don't look any different from a file update. I really need the ChangeKind to actually be ChangeType that tells me what the SyncFramework has detected in terms of operating on a File, not a generic SyncItem (File-related operations contained in ChangeType like "delete, create, update, rename" instead of "ghost, updated, deleted, unknown").
Will someone help out please? How can I get the ChangeType from each change in the ChangeBatch, instead of "ChangeKind" and how do I get the FileData (FileInfo) of each file that has been detected as changed - even the deleted files (or at least the last known path that the deleted file occupied).
uint batchSize = 0;
SyncKnowledge sk = new SyncKnowledge();
this.DirSyncProvider.GetSyncBatchParameters(out batchSize, out sk);
object cdrObject = null;
this.DirChanges = this.DirSyncProvider.GetChangeBatch(batchSize, sk, out cdrObject);
IChangeDataRetriever changeDataRetriever = (IChangeDataRetriever)cdrObject;
this.DirSyncProvider.Configuration.CollisionConflictResolutionPolicy = CollisionConflictResolutionPolicy.SourceWins;
this.DirSyncProvider.Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.SourceWins;
List<SyncId> deletedItems = new List<SyncId>();
foreach (var change in this.DirChanges)
loadChangeContext = new UserLoadChangeContext(this.DirSyncProvider.IdFormats, change);
if (change.ChangeKind != ChangeKind.Deleted)
fileDataRetriever = (IFileDataRetriever)changeDataRetriever.LoadChangeData(loadChangeContext);
//Operate on Changed File