Click here to Skip to main content
Licence CPOL
First Posted 7 Jun 2007
Views 17,787
Downloads 307
Bookmarked 23 times

Synchronize up to seven folders with System.IO.FileSystemWatcher in .NET

By | 7 Jun 2007 | Article
An app to synchronize up to seven folders with System.IO.FileSystemWatcher in .NET.

Introduction

With this app, you can monitor seven folders without any CPU loss .. and add up to seven folders to mirror in real time!

This application can also manage directories and subdirectories and the operations Add, Delete, Edit etc.

Background

The solution uses the WatchFolder class from the .NET Framework.

watchfolder.Path = source12.Text
watchfolder.Filter = "*.*" ' filter1.Text
watchfolder.NotifyFilter = IO.NotifyFilters.DirectoryName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.FileName
watchfolder.NotifyFilter = watchfolder.NotifyFilter Or IO.NotifyFilters.Attributes
watchfolder.IncludeSubdirectories = True
AddHandler watchfolder.Renamed, AddressOf logchanger
AddHandler watchfolder.Created, AddressOf logchange
AddHandler watchfolder.Changed, AddressOf logchange
AddHandler watchfolder.Deleted, AddressOf logchange
watchfolder.EnableRaisingEvents = True

Using the Code

Add these Imports statements:

Imports Microsoft.Win32
Imports System.IO

Here is how we use the code:

AddHandler watchfolder.Renamed, AddressOf logchanger
AddHandler watchfolder.Created, AddressOf logchange
AddHandler watchfolder.Changed, AddressOf logchange
AddHandler watchfolder.Deleted, AddressOf logchange

Points of Interest

The app can save all input from the user the first time inside the Registry.

History

  • Version 1.1.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

GC9N



Greece Greece

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 1 PinmemberMichael B. Hansen1:07 6 May '10  
GeneralSome background info would have been nice PinmemberAndreas Kroll13:03 12 Jun '07  
GeneralRe: Some background info would have been nice PinmemberAlberto Venditti23:06 13 Jun '07  
QuestionWhy seven ? Pinmemberdanidanidani7:59 7 Jun '07  
AnswerRe: Why seven ? PinmemberGC9N8:24 7 Jun '07  
JokeRe: Why seven ? Pinmemberdanidanidani9:39 7 Jun '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 7 Jun 2007
Article Copyright 2007 by GC9N
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid