Bryant Likes's Blog

It's all about WebData

Recent Posts

Tags

News


  • Windows Live Alerts
    View Bryant Likes's profile on LinkedIn

    Me

    Get Microsoft Silverlight
    by clicking "Install Microsoft Silverlight" you accept the
    Silverlight license agreement


    The posts on this weblog are provided "as is" with no warranties and confer no rights. The opinions expressed herin are the personal opinions of the individual authors and do not represent the views of Avanade in any way.

Community

Email Notifications

Archives

Remote File Sync using WCF and MSF

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.

 

Technorati Tags: ,

Comments

Sync Framework Forum said:

A user testing your sample has posted a question regarding your sample here:

http://forums.microsoft.com/sync/ShowPost.aspx?PostID=2663694&SiteID=75

"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."

# January 15, 2008 3:47 PM

Jeffrey Peters said:

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.

# January 22, 2008 5:06 PM

owen ong said:

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.

# February 19, 2008 8:18 AM

Chandrashekar Kollipara said:

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."}

# March 10, 2008 11:07 AM

Rayman said:

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

# May 2, 2008 8:22 AM

robert said:

Hey Thanks!  This was just the example I was looking for!  Great work!

# July 29, 2008 2:55 PM

Philippe said:

Hi, this is just the sample I needed.

Could you please update the sample to support the RTM version of MSF.

# October 1, 2008 11:32 PM

Ammar said:

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?

# December 9, 2008 1:49 PM

Rajan said:

Could you provide working Sample code for MS Sync File System service CTP2 with Using WCF

# March 2, 2009 2:53 PM

ravi said:

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.

# March 3, 2009 8:19 AM

Kumaran said:

Can you please provide a working sample with the latest sync framework.

# April 1, 2009 3:04 PM

The Synchronizer said:

I spent years building sync solutions in Microsoft! I loved it! Sync and replication logic is so challenging

# May 28, 2009 10:27 PM

elicStitwot said:

Thank you for that. It's really good stuff.

I love to browse blogs.sqlxml.org.

<a href=http://teethwhiteningwebsite.wordpress.com>boca raton teeth whitening</a>

# June 17, 2009 11:45 AM

LeraJenkins said:

There was a mistake

# June 21, 2009 5:45 PM

strykerszero said:

People must learn to eat moderately to effectively lose weight. It seems as if as the American population increases, so do our appetites. In the past, a simple, leafy sandwich with a glass of milk was enough to satisfy our hunger. How, however, to fill ourselves up, we flat belly diet cookbook eat huge portions, large side entrées, and a gargantuan carbonated drink. If one walks into some fast food restaurants, one can get their meal enlarged or "Super sized". We must go back to our old ways of limiting our food intake. One should eat until there are full, not comatose.

We must not eat too much, but we should <a href=www.squidoo.com/Flat-Belly-Diet-Cookbook>Flat Belly Diet Cookbook</a> eat just enough to maintain our body's need for energy. Overeating has bigger ramifications than most people think. However, Americans became aware of this "overeating epidemic" when they "flocked to see Super Size Me, Morgan Spurlock's documentary about what happens when you eat nothing but McDonald's food for a month. Now McDonald's is discontinuing its Super Size option" (Lemonick).

Eating nutritional foods is necessary in order to successfully lose weight. A misconception people have is that they think it is okay to eat a whole box of chocolate chip flat belly diet cookbook cookies after enjoying a 5K run in the afternoon. This can be one of the worst things a person can do to his body. Although one exercises everyday of his life, one also has to eat healthy.

# June 25, 2009 5:17 PM

Partha said:

Hi Bryant,

Thanks for the code. It was really helpful.

I have used your code for a project I am working on and have done some major enhancements on top of it. However, some lines of code from your solution will still be present. Hope you do not have any objection to that.

Thanks once again for sharing the solution.

# June 30, 2009 11:10 PM

Kidslagsplups said:

Greetings to All!

I just wanted to note on the contribution of this community here. It's awesome.

I wanted to give a little something back myself

There is a site that has been excessively helpful to myself and some associates of mine. That site is OnlineComputerHelpers.com and they offer remote <a href=http://www.onlinecomputerhelpers.com>computer repair</a>

I hope that my offering has been substantial and you also are able to use their services just as I have.

# July 2, 2009 12:40 PM

PeterMontee said:

Bravo, your idea simply excellent

# July 2, 2009 2:52 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)