FileSyswatcher is a windows service that monitors a specified path on
your disk drive. It will check for all changes to a directory including
it's subdirectories and files. The application enables you :
To keep check on changes made to directories.
Log which user made what changes to which directories and files on what date
Generate a HTML report for the daily logs.
FileSysWatcher is written in C# and .Net 1.1. FileSysWatcher will run
on all MS Windows platforms that support Windows Services. It's a Windows
Service application that uses many powerful features of the .NET platform.
I developed this application to demonstrate how to create a windows service. It
also demonstrates the use of the
FileSystemWatcher object. It demonstrates how
to catch various file change events such as Delete, Create, Rename and Change.
Other feature's used are XML, XSLT, FileSt
StreamWriter of the XML and IO namespaces respectively.
Using the code
The application has the following files:
- Util.cs bin\Release\FileSysWatcher.exe.config:
This file is generated every time you compile the application.
Its a copy of the App.Config file. This is the application configuration file
where I have added key-value pairs.
This is the xsl file which is used to generate the HTML report
from the xml.
This is the application configuration file where I have added
key-value pairs. When application is compiled it generates a file called
FileSysWatcher.exe.config which is copied to the bin\Release folder. It
contains following values:
LOGFILENAME file path where log file is created.
path where errors during execution are logged.
path to monitor.
This is the actual service file. It has the FileSysWatcher
class which inherits from the ServiceBase class. It has methods such as,
It also hosts the
FileSystemWatcher object which exposes the
These events are fired everytime a file/directory is changed,
deleted, renamed or created.
This contains a static
Print() method to generate the HTML
This is a ServiceInstaller which is autogenerated. No code
has been modified in this class.
This contains utility methods.
Points of Interest
Some Interesting points:
Generating HTML using XML and XSLT.
Monitoring File and Directory Activity
Installing and UnInstalling a Windows Service.
- First Update : 02nd September 2004.