Search code examples
c#microsoft-sync-framework

Microsoft Sync Framework, Detect changes first and then sync


I have two folders that have some files inside them, I want to use Microsoft Sync Framework in a way that first it detects changes in a folder, if there is any, then carry out the Sync operation with the other folder.

The idea behind detecting the change on the folder is that I could query on that change and can do some operations first, before sync.

Any idea is also welcome to use the MSF with other techniques to achieve the same.

I have tried the sample code example given in this link https://msdn.microsoft.com/en-us/library/mt763483.aspx

But it first sync the folders and then fire some events. I try to fire the events first but it doesnt work. I am a beginner in all of this so any help in this regard is higly helpful.


Solution

  • There is an event "ApplyingChange" which is triggered whenever there is a change in the folder. In this event, I first check the change and then call the "e.SkipChange" so that I only detect that there was a change in either the source folder or destination folder, then in the next call of this event I dont call the skip change and carry out the change or synchronization.