File Replication

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,

Who is Participating?
Z_BeeblebroxConnect With a Mentor Commented:

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.

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.

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.

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.


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 : )
raybettsAuthor Commented:
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.

raybettsAuthor Commented:


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.


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.