Feed Icon  


  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics


Open Source Projects



Remote File Sync using WCF and MSF

Posted in WCF | .NET | Sync Framework at Thursday, January 3, 2008 3:41 AM Pacific Standard Time


One of the things I've been looking into in my free time is the Microsoft Sync Framework (MSF) (currently in CTP mode). The MSF is:

[A] comprehensive synchronization platform enabling collaboration and offline for applications, services and devices with support for any data type, any data store, any transfer protocol, and network topology.


Included with the SDK is a sample called the Managed NTFS Sample which demonstrates how to create your own file sync provider for local files. This works pretty well for local files, but what I really want to do is a remote file sync over the Internet. The reason is that I built a family photo sharing website for my family and I use FolderShare to copy the files from each family member's computer up to my server. However, FolderShare only supports a limited number of shares and only supports 10,000 files per share. So with the idea of creating a custom FolderShare type of service I started to customize the sample. 

The remote file sync sample I created is still pretty rough around the edges since my goal was to just get it working. The sample is also only a one-way sync meaning file changes are only sent to the server and not back to the client (which is what I wanted). The service is a WCF service exposed via a website and right now the client is just a console application.

You can download a working sample of the code here.

I still have more to do on it and if there is enough interest I'll create a project on CodePlex for it. One of the first enhancements I'd like to make is to use ASP.Net membership to handle security and then create folders for each user instead of passing the root path in the sync service. There is lots of room for improvement.


Tuesday, January 15, 2008 7:47:35 AM (Pacific Standard Time, UTC-08:00)
A user testing your sample has posted a question regarding your sample here:


"I've been looking around at Brian Likes' demo app using FileSync. I fired up the service on on computer, and then the client on the other. The upload sync worked...once. On every subsequent test, I've gotten an InvalidOperationException on the syncAgent.Synchronize call, with the message that "LastWriteTimeUtc not yet set." I couldn't find a property called LastWriteTimeUtc in any object in the list of local variables, and both an MSDN and a Google search didn't yield any sort of usable results either. Does anyone have any idea what the cause could be? Thanks."
Tuesday, January 22, 2008 9:06:04 AM (Pacific Standard Time, UTC-08:00)
I just wanted to thank you for posting this code. I have been trying to get my head around how to accomplish this today and this should really help out. Please continue to post updates, I will appreciate it very much.
Jeffrey Peters
Tuesday, February 19, 2008 12:18:16 AM (Pacific Standard Time, UTC-08:00)
Thx for ur code. I m new to MSF but i wish to try ur code and learn something from it. So, can u briefly let me know the steps on how to host ur code in iis and how to use ur client console application in remote computer? i doesn't which classes are needed to host and which classes are needed in client side. Ur help are appreciated. thx again.
Monday, March 10, 2008 3:07:56 AM (Pacific Standard Time, UTC-08:00)
Change batch cannot be serialized any more with CTP2 the following error occurs any input would be greatly appreciated
{"The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://ektron.com/filesyncservice:sourceChanges. The InnerException message was 'There was an error deserializing the object of type Microsoft.Synchronization.ChangeBatch. Xml representation of the object is invalid.'. Please see InnerException for more details."}
Chandrashekar Kollipara
Friday, May 2, 2008 1:22:58 AM (Pacific Daylight Time, UTC-07:00)
I downloaded the sample and tried to complile with VS 2008 and got the following error. I did install the latest version of Microsoft Sync Framework:

Error 1 The type or namespace name 'ChangeBatchBuilder' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\RAryan\Desktop\RemoteSync\RemoteSync.Common\SyncDetails.cs 68 13 RemoteSync.Common
Tuesday, July 29, 2008 7:55:56 AM (Pacific Daylight Time, UTC-07:00)
Hey Thanks! This was just the example I was looking for! Great work!
Wednesday, October 1, 2008 4:32:20 PM (Pacific Daylight Time, UTC-07:00)
Hi, this is just the sample I needed.
Could you please update the sample to support the RTM version of MSF.
Tuesday, December 9, 2008 5:49:00 AM (Pacific Standard Time, UTC-08:00)
Is there a way to synchronize two folders over the web? Can we use MS Sync Services to synchronize the Source and Destination folder which are web URL addresses (such as http:\\www.abc.com\srcFldr & http:\\www.abc.com\destFldr) instead of C:\sync1 & C:\sync2. If yes, do you have an example.

I was able to comile your code, but when I run it I am getting object null ref error when calling SyncOrchestrator's Synchronize function? any idea why?
Monday, March 2, 2009 6:53:55 AM (Pacific Standard Time, UTC-08:00)
Could you provide working Sample code for MS Sync File System service CTP2 with Using WCF
Tuesday, March 3, 2009 12:19:34 AM (Pacific Standard Time, UTC-08:00)
Hi Bryant,Thnx for ur code.
I am getting error "Operation is not valid due to the current state of the object." in ProcessChangeBatch() method at
localVersions = service.GetChanges(folderPath, sourceChanges);
any idea why?
I tried to modify code for latest version of sync framework.
Wednesday, April 1, 2009 7:04:51 AM (Pacific Standard Time, UTC-08:00)
Can you please provide a working sample with the latest sync framework.
Sunday, August 23, 2009 6:51:53 PM (Pacific Daylight Time, UTC-07:00)
I would need this example with the latest synchronization framework version
Comments are closed.