使用 Microsoft Sync Framework 跨网络同步文件
此处给出的文件同步示例 - http://code.msdn.microsoft.com /Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3424 仅讨论在同一台计算机上同步文件。有没有人遇到过使用 WCF 之类的东西来使其能够跨网络处理文件的工作示例?
科比的示例 - http://bryantlikes.com/archive /2008/01/03/remote-file-sync-using-wcf-and-msf.aspx 不完整,只是一种单向同步,不太理想。
The file synchronization example given here - http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3424 only talks about syncing files on the same machine. Has anyone come across a working example of using something like WCF to enable this to work for files across a network?
Bryant's example - http://bryantlikes.com/archive/2008/01/03/remote-file-sync-using-wcf-and-msf.aspx is not complete and is only a one way sync and is less than ideal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只要您有可用的网络共享,同步框架就可以跨网络同步文件。
在 FileSyncProvider 的构造函数中,将 rootDirectoryPath 设置为您具有读写权限的网络共享位置:
要以这种方式进行双向同步,您需要为源系统和目标系统创建一个 FileSyncProvider 并使用 SyncOrchestrator为您做繁重的工作。
一个例子:
它的作用是定义两个文件同步提供程序,编排器将在两个方向上同步文件。它跟踪提供程序中设置的目录中文件的创建、修改和删除。
此时所需要做的就是在 SyncOrchestrator 上调用 Synchronize:
The Sync framework can synchronize files across the network as long as you have an available network share.
In the constructor of the FileSyncProvider set the rootDirectoryPath to a network share location that you have read and write permissions to:
To do a two way sync in this fashion you will need to create a FileSyncProvider for both the source and destination systems and use the SyncOrchestrator to do the heavy lifting for you.
An example:
What this does is define two filesync providers and the orchestrator will sync the files in both directions. It tracks creates, modifications, and deletes of files in the directories set in the providers.
All that is needed at this point is to call Synchronize on the SyncOrchestrator: