Detecting File Changes

The Sync Framework file synchronization provider automatically detects changes that were made to files and folders in the synchronization scope. 

Change detection must be performed before the synchronization session is started. By default, change detection is performed automatically the first time Sync Framework calls GetChangeBatch or ProcessChangeBatch on the provider.

Managed code If the application specifies the ExplicitDetectChanges flag when it initializes the provider, the application must explicitly call the DetectChanges method before it starts the session.

Unmanaged code If the application specifies the FILESYNC_INIT_FLAG_DISABLE_IMPLICIT_DETECT_CHANGES flag when it initializes the provider, the application must explicitly call the IFileSyncProvider::DetectChanges method before it starts the session.

Sync Framework has a built-in algorithm for detecting changes that are made to the files and folders in the synchronization scope.

A change is reported when any of the following properties has changed:

  • The last modification time on a file.

  • If hashing is enabled, the value of the hash that was computed for the file.

  • The file size.

  • The file or folder name. This check is case-sensitive.

  • Any of the file attributes that are handled by the provider.

A file move or rename is reported when a file is found that has the same creation time, size, and hash value (when hashing is being used) as a previously known file, but the file has a different name or path. If more than one file is found that meets these criteria, Sync Framework acts as if the original file was deleted and new files were created.

Sync Framework treats a folder move or rename as if the old folder was deleted and the new folder was created. The files in the folder are reported as moves. Therefore, in this case, file data does not usually have to be re-sent.

If the application specifies the CompareFileStreams flag (for managed code) or FILESYNC_INIT_FLAG_USE_HASHING flag (for unmanaged code) when it initializes the provider, the provider computes a hash value for each file by using all the contents of the file stream. The provider then compares these hash values, allowing for more robust change detection at the cost of slightly decreased performance.

Show: