Export (0) Print
Expand All

Controlling Which Files Are Synchronized

Sync Framework provides several ways to control which files and subfolders are included in the synchronization scope. Static filters exclude or include files and subfolders based on settings that are specified by the application when the provider is initialized. Dynamic filtering is achieved by using an event notification that the application can register to receive.

Excluded and Unsupported File and Folder Types

The following files are always excluded from the synchronization scope and are completely ignored:

  • Thumbs.db when the hidden and system attributes are set.

  • Desktop.ini when the hidden and system attributes are set.

  • The metadata file that was specified when the provider was initialized.

  • A file that has the offline or device attribute set.

  • A folder that has the reparse point attribute set.

Folders that contain Briefcase folders are not supported and should not be included in any synchronization scopes.

Static Filters

Static filters can be set to exclude files by name (including wildcard names) and by attribute. Static filters can also be set to exclude the contents of whole subfolders, but wildcards are not supported for subfolders. Or, an explicit list of file names to include (including wildcard names) can be specified. To be included in the scope, a file or a folder must pass all filters. For example, if all files that have a .txt extension are excluded from the scope and MyFile.txt is specified in the list of files to explicitly include in the scope, MyFile.txt will be excluded from the scope because of its .txt extension.

To specify a static filter by using managed code

  1. Create a FileSyncScopeFilter object. Exclusion or inclusion properties are set in the FileSyncScopeFilter constructor, such as by specifying "*.txt" for the fileNameExcludes parameter to exclude all files that have a .txt extension from the synchronization scope.

  2. Pass the filter to the FileSyncProvider constructor. When this provider is used as the source provider in a synchronization session, only files that pass the specified filters will be included in the synchronization scope.

To specify a static filter by using unmanaged code

  1. Create an IFileSyncScopeFilter object by using IFileSyncProvider::CreateNewScopeFilter.

  2. Set exclusion or inclusion properties on the filter object, such as by specifying "*.txt" to the IFileSyncScopeFilter::SetFilenameExcludes method to exclude all files that have a .txt extension from the synchronization scope.

  3. Pass the filter to IFileSyncProvider::Initialize. When this provider is used as the source provider in a synchronization session, only files that pass the specified filters will be included in the synchronization scope.

Skipping Files

Files can be dynamically skipped during synchronization by handling an event raised by the provider. This event occurs during change application. It is raised by the destination provider one time for each change, before the change is applied to the destination replica. When the event handler receives the event, it can specify that the change should not be applied to the destination replica.

Managed code Register a handler for the ApplyingChange event. To skip a change, set the value of the SkipChange property to true in the event handler.

Unmanaged code Pass an IFileSyncProviderCallback object to IFileSyncProvider::Initialize to register to receive event notifications. To skip a change, set the value of the pfSkipChange parameter to TRUE in IFileSyncProviderCallback::OnApplyingChange.

See Also

Show:
© 2015 Microsoft