Hi,
Yesterday I was playing around with some directories and a requirement came in where by I had to keep watch on the changes in the directory structure. My requirement was to update user as soon a there was a change in a file in the given directory.
I first thought of many ways to do it. By the end I found it was pretty easy to be done. We have to use the FileSystemWatcher class in the System.IO to get the job done.
Lets say we want a notification to be there when there is a change the D drive (D:\). If you want to also make the notification for sub directories then we need to set the IncludeSubdirectories to true. Here is a small code on how to use the component.
FileSystemWatcher watchFiles = new FileSystemWatcher(@"d:\\");
watchFiles.IncludeSubdirectories = true;
string dtCur = DateTime.Now.ToLongTimeString();