Click here to Skip to main content
13,351,443 members (47,404 online)
Click here to Skip to main content
Add your own
alternative version


40 bookmarked
Posted 27 Jan 2008

Folder Listener: A Tool to Watch File System Activity in any Folder

, 27 Jan 2008
Rate this:
Please Sign up or sign in to vote.
This tool is for the tester and developer to track any file system activity to a particular folder


Most of the time when you are doing some development or testing, you might need to know what changes are made in a particular folder. This requirement frequently arises when you are testing /developing software that copies /delete files in the background without user intervention; for example background update and installation/un-installation of software product. It can also be useful when you want to know the intermediate file that a particular application creates in a particular folder.

Technology Used

This application is based on Microsoft's .NET Framework 2.0 and is written in C#. .NET Framework provides a component FileSystemWatcher that is used to track and listen to the changes made in a particular folder. You may find several articles on this component, so I am not going to explain the working code. Below is the code segment that allows you to create a FileSystemWatcher.

Using the Code

It uses the FileSystemWatcher component of the .NET Framework. The main code snippet is given below:

FileSystemWatcher fsw = new FileSystemWatcher();
fsw.Path = textBox1.Text;
fsw.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | 
                   NotifyFilters.DirectoryName | NotifyFilters.FileName;
fsw.Changed += new FileSystemEventHandler(OnChanged);
fsw.Created += new FileSystemEventHandler(OnCreated);
fsw.Deleted += new FileSystemEventHandler(OnChanged);
fsw.Renamed += new RenamedEventHandler(OnRenamed);
fsw.EnableRaisingEvents = true;

Tool Limitations

This tool is designed to listen to a single folder at a time. However in future, I will update it for multiple folders.

Using the Tool

Use of this tool is very simple. Just run the tool and select the folder you want to listen to or track.


  • 27th January, 2008: Initial post


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


About the Author

Ashwini K Singh
Software Developer HCL Technology
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralHelp me please Pin
tranquocvietdanang2-Aug-10 23:00
membertranquocvietdanang2-Aug-10 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web02 | 2.8.180111.1 | Last Updated 27 Jan 2008
Article Copyright 2008 by Ashwini K Singh
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid