Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


File Replication

Posted on 2001-06-14
Medium Priority
Last Modified: 2013-11-13
Basically guys Im after some pointers in the right direction here.....

I have been asked to write an app that will replicate Word documents in various directories amongst 3 sites that belong to a branch.  So basically they want all three sites at some stage or another to have the same versions of files, when users update them.  

The plan is to have a client admin tool, where somebody can specify the directories (source and target) and the replication frequency. EG.

From: c:\windows
To:   I:\MainDataPool
Frequency:  Every 1/2 hour

We will then have a "watcher" server side util, that with the help of a few api's, will watch these directories, and build up up a log of which files change in these directories.

This Im okay with, but I thought you may need it for a full picture.

The problematic area is the "Replicator", which also needs to be a server side util, preferably running as a service.

This is where Im having problems trying to think of the best way to implement this.  As mentioned several directories will potentially have different replicating intervals, so i was thinking of having an apartment threaded util, that the watcher creates a thread for every time interval / directory.  But it gets a bit messy then in trying to keep track of which files need replicating as potential we have z files on x threads, which belong to which.  So I am a little confused.

Any pointers and / or psuedo code would be great.

If you need anymore info then shout.

PS.  Dont worry about two sites making changes to the same file at roughly the same time.  We've decided to put both files in a temp dir and send an email to a responsible person so they can sort out the mess!

Cheers guys,

Question by:raybetts
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 22

Expert Comment

ID: 6193077
My first question is whether the replication is necessary...

* Is it for the purpose of creating redundancy to prevent loss of data?
* Is it because the competing systems are off-line from each other?

Why no just put the file on a central server for access to whomever gets it first.  If it's a Word doc, when another user goes to access it, Word will display a message and ask if you'd like to open it read-only.

Expert Comment

ID: 6193082

Couldn't you just store all of the replication times' settings in one place, like a database or a file, then have the server service poll this file every 30 seconds or something to see if there is anything it needs to do. Also, rather than creating watched folders on all of the machines, why not have the central server store the last modified date of all of the files and then when a replication is scheduled, check the last modified date and replicate and update the central list if necessary.


Expert Comment

ID: 6193812

How about using this:

Description: Transfer files from one computer to another using Winsock (8K)

And/OR this:

A+ Winsock Transfer *NEW* both in one form. App & Client - Easy. * A MUST HAVE*

Description: This is a re-make of the code I posted yesterday. Now you it consists of only one form who is able to receive and send files. You can use it to provide your app with internal filetransfer or even chats. Please visit for more! -------- Thats what I posted yesterday! " This code allows you to transfer files from one pc to another using winsock. Well it does not use only api declarations but it works. I comment it in english so i hope you can understand it because i'm german. I made that example because a lot of winsock transfer file toolkits are not precise enought. Some do not use send complete and some examples show you how your file become bigger and bigger after every transfer because they do not check the file size! I do not say that my one is perfect but much better than most of the others. For example I do not like the filesize check-routine... if you know a better way to fix that, please send me your ideas to The "FILEINFO" routine should also made in a better way... you should take another winsock to transfer fileinfos. I also included the transfered bytes per second in that sample! "

ANd/OR this:

Description: Transfer files over a network. Set the packet size, cancel, shows rate of transfer. Problems threading it, if you can help on the multi-thread/transfer please do, and vote if you like =)
Rename the two included files, one is an exe, one is the ocx.

My point is:  Make your own server-client progam.  The clients will keep checking for files every minnute but the server will only send the files after 30 mins or whichever values of minutes you prefer.

That's it!

glass cookie : )
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 6198610
Guys thanks for the info.


Its not for data loss, its just so everyone has the use of the same version of files.

Yes having a central server would be nice, but our client has a pretty crap network infastructure, so only admin type cross network rotuines are allowed.


Nice idea, I will discuss this with my boss on monday.  Is this a programming solution or something I would set up in NT??????


thanks for the tonnes of info, will check your stuff out on monday.  I work away from home, so weekends are me and wife time!

Will see you guys through the week.


Accepted Solution

Z_Beeblebrox earned 600 total points
ID: 6198748

My suggestion would require you to write a program which would run on a server somewhere (it could be one of the client computers) and manage all of the files. You shouldn't need any of glass_cookies' suggestions as long as you can map a network share to the various computers. If you can, then you can just do a file copy. Probably the easiest way to do this would be to write a little VB program which would run on start up on one of the computer and every 30 seconds or so would check a file which contained all of the various files to be replicated and where they should be replicated to, as well as that file's last modified date. It could then check each of the files' modified dates against the dates stored in that file and replicate where the dates are different.

You would probably also want to throw together a little client program which people could use to configure which files were to be replicated. This program could run on any computer and would modify the file on the server that does the replication.

Depending on how sophisticated you want this to be, you may want to consider using a database like Access to store all of the various settings.


Author Comment

ID: 6208119


It was also the idea I sort of came up with (honest!).  I just had brain blockage last week (thus the reason for throwing the problem to you guys), and thought the route i was going down was a dead end, but you confirmed that its the way you would tackle it.

So Ive just finished my client app, and over the next week should have my directory watcher in place and also the replicator.

Thanks to everyone else, I appreciate the effort you all put in....we all lead busy lives after all.



Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question