Click here to Skip to main content
Click here to Skip to main content
Go to top

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

Introduction

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.

History

  • 27th January, 2008: Initial post

License

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

Share

About the Author

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

Comments and Discussions

 
GeneralMy vote of 5 PinmemberVijaysubs17-Dec-12 3:09 
GeneralHelp me please Pinmembertranquocvietdanang2-Aug-10 22:00 
GeneralThanks PinmemberNitin Sawant23-Sep-09 5:11 
GeneralGreat and thorough job Pinmemberpsi_u16-Oct-08 9:25 
GeneralNice Pinmemberbartd2-Apr-08 7:19 

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.

| Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 27 Jan 2008
Article Copyright 2008 by Ashwini K Singh
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid