BPSoftware.com
Home   Utilities   Purchase   FAQ   Support   Contact        
Shareware Utilities
 APrintDirect
 AIconExtract
 AFile Attribute Manager
Freeware Utilities
 AddrMon
 AFileSync
 ASysIcon
 B&P Table Utilities
 BPACLer
 BPSNMPMon
 BPSNMPUtil
 CharCount
 Delphi® Components
 MacAddr
Miscellaneous
 BPSoftware Blog
 Conversion Utility
 Rock Paper Scissors Game
 Random Number Generator
 DayLightTime
 BlogRoll
 Purchase Shareware
 Support
 Privacy

 


Monday, October 01, 2007
Let's Synchronize Some Files

Recently, I posted about the new addition to my backup strategy; a NAS. My intended use of this device is to have a hot backup of my files. The system I was using before was not capable of storing the amount of data I need backed up, nor was it easy to manage. I modified the set of xCopy batch files that I used for my backups to write the files to the NAS.

This system worked fine, but I needed more. I manage a lot of data and have a lot of files. I wouldn't want to lose any in the event of a system failure. The one problem I see with using this process is the lack of a real time solution.

I was in search of a solution that would offer me real-time synchronization between my files and the NAS. I didn't have to search very far. The .NET Framework includes the FileSystemWatcher Class.

The FileSystemWatcher Class "Listens to the file system change notifications and raises events when a directory, or file in a directory, changes." (quoted directly from MSDN) After reading through this class I quickly whipped up a solution. I developed my own FileSync class that allowed me to easily synchronize files between my remote and local storage. I created a Windows Service (threaded) built around my class (the screen shot in this post is from a sample app I used to test my class) so that I could have the FileSync class running and keeping my files in sync without me needing to do anything. Here is the unit I created:


1using System;
2using System.IO;
3using System.Diagnostics;
4
5namespace BPSoftware
6{
7 class FileSync
8 {
9 private FileSystemWatcher watcher;
10
11 Fields
40
41 Constructors
62
63 Methods
115
116 Events
165 }

166}

167

Labels: , ,

posted by Brad Prendergast at 1:09:00 AM
Comments:
Links to this post:

Create a Link

Recent Posts
 Compact that Virtual PC
 Is it Hammer Time?
 DSOFile and Summary Properties
 ShellExecuteEX and ShellExecuteInfo Revisited
 A ToolStripMenuItem and a Check
 Who is copying your web site?
 A little FileIconInit for the System Image list
 Code Monkey
 A DataGridView, DataGridViewCheckBoxColumn, DataGr...
 Those Commercials
Archives
 October 2005
 November 2005
 December 2005
 January 2006
 February 2006
 March 2006
 April 2006
 May 2006
 June 2006
 July 2006
 August 2006
 September 2006
 December 2006
 January 2007
 February 2007
 March 2007
 September 2007
 October 2007
 November 2007
Powered by Blogger