473,387 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Creating a service to monitor a folder structure

MAB
I need to create a service (or something else) to monitor the coming and
goings of files (& possible folders) beneath a root folder. This service
need to know the path/FileName of any new files so it can add data to a
database. If files are deleted the service needs to know the path/FileName
too for it can delete data from the database. The service will (or execute
another application that will) query inside the added documents for other
data to be added to the database.

I would be greatful for any pointers.
Jun 24 '06 #1
1 2495
Hi MAB,

I suggest creating a Windows Service that uses a
System.IO.FileSystemWatcher. The FileSystemWatcher class exposes events for
operations that you require such as adding a new file and deleting a file.
View MSDN help on FileSystemWatcher for more information and examples.

If you want to buffer changes and handle them in groups just use a
System.Threading.Timer and a buffer.

1. Enable the timer using the Timer.Change method when a FileSystemWatcher
event is raised but only if the timer is not already running. Checking the
Timer state will require a global variable that you must set and reset at
the appropriate times.
2. Add the ChangeType supplied by the FileSystemEventArgs in your event
handler to a System.Collections.Generics.Dictionary<System.IO.F ileInfo,
System.IO.WatcherChangeTypes> or a List, Typed with a custom object, which
is probably the better choice.
3. In the Timer event handler reset the global "timer started" variable and
perform the batch operation.
4. You'll probably want to synchronize the code in your TimerCallback with
your FileSystemWatcher event handlers to ensure that no changes go
unbuffered. You can do this using WaitHandles.

HTH

"MAB" <MA*@discussions.microsoft.com> wrote in message
news:44**********************************@microsof t.com...
I need to create a service (or something else) to monitor the coming and
goings of files (& possible folders) beneath a root folder. This service
need to know the path/FileName of any new files so it can add data to a
database. If files are deleted the service needs to know the
path/FileName
too for it can delete data from the database. The service will (or
execute
another application that will) query inside the added documents for other
data to be added to the database.

I would be greatful for any pointers.

Jun 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Troy Murphy | last post by:
The help file for Visual Studio .NET version 1 had a Walkthru for installing a Windows Service that would monitor a folder. Version 1.1 does not seem to have that example anymore. Could someone...
2
by: Mark | last post by:
I've heard that you could program a service to Manage File folders, etc. My problem is that I have to monitor files in a folder and when locks are released from them by users, move them to...
1
by: Adrian | last post by:
I am trying to use FileSystemWatcher (FSW) to monitor a folder. The only problem is this folder is on FTP server located on DMZ (outside my domain) and FSW does not allow me to pass credentials in...
9
by: Rotzooi | last post by:
Hi, I have a VB.NET Service application that's running fine under the Local System account. But for configuration purposes I don't want to be dependent on modifying the registry manually or...
7
by: Ahmed Perlom | last post by:
Hi all, I am trying to start a windows application that has a GUI from a Windows service written in .NET 2.0. I have been searching on this for few days now with no avail. When using the...
3
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
0
by: =?Utf-8?B?U2ltb25EZXY=?= | last post by:
Hi All I would like to install the same Windows Service project on the same server under different names, one for each customer. I have been able to do it but I would like an expert opinion as...
3
by: Nokao | last post by:
I use db2 9 express-c Hi... I'm having that problem... .....every less-than-10-seconds, a entry like that (I displayed that entry with the command db2evmon -db 'MYDATABASE' -evm...
4
by: Steven De Smet | last post by:
Hello, This is my first post. I searched on the internet for answers but I was unable to solve my problem. So I hope that you guy's can help me with my VB.NET problem I tried to create a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.