Compartir a través de


Synchronizing File Synchronization Provider with Other Providers

This topic describes how to create a managed application that enables a file synchronization provider to synchronize with another Sync Framework provider. In this case the other provider is a simple provider, but you could also use a standard custom provider. For more information about simple providers, see Implementing a Simple Custom Provider.

There are two main requirements for the application:

  • The application must implement IFileDataRetriever as the data transfer interface between the two providers.

  • The simple provider must use the same format for IDs that file synchronization provider uses: a 16-byte GUID for replica IDs; A 16 byte GUID that is preceded by an 8-byte prefix for item IDs; and a 4-byte integer for change unit IDs.

Managed Code Examples

The examples in this section show some of the code that is relevant to synchronizing a file synchronization provider and a simple provider, with a focus on the ID and transfer interface requirements. To view this code in the context of a complete application, see the "Sync 101 - Synchronizing a File Synchronization Provider with a Simple Provider" application that is available on Code Gallery.

The following code example shows how the definition of the IdFormats property for the simple provider matches the requirements stated earlier.

The following code examples show two of the methods that are required for simple providers: LoadChangeData(ItemFieldDictionary, IEnumerableSyncId, RecoverableErrorReportingContext) and InsertItem(Object, IEnumerableSyncId, RecoverableErrorReportingContext, ItemFieldDictionary, Boolean). Much of the code in these methods is specific to implementing a simple provider, but there are two areas to note:

The following code example creates the SimpleFileDataRetriever class, which uses AbsoluteSourceFilePath and RelativeDirectoryPath to identify file locations, and FileData and FileStream to transfer the actual data.

The following code example synchronizes the two providers. The synchronization process is the same as if you synchronized two file synchronization providers or two simple providers: implementing the IFileDataRetriever interface and using the appropriate ID formats ensures that data is transferred in the correct way.

Vea también

Conceptos

Implementing a Simple Custom Provider

Integrating Data from Different Providers

Synchronizing Files