intelliproject logo

Location: Desktop development - C#    License: The Intelliproject Open License (IPOL)

Monitoring File System using FileSystemWatcher Class

Posted by Silviu Caragea

Explain how to watch for changes in files and subdirectories of a specified directory

Skill: Intermediate

Posted: 11/10/2008

Views: 962

Rating: 5.00 /5

Popularity: 1.51

Sign Up to vote for this article

Introduction

The FileSystemWatcher class is used to watch for changes in a specified directory. You can watch for changes in files and subdirectories of the specified directory. Also you can create a component to watch files on a local computer, a network drive, or a remote computer.

The FileSystemWatcher is designed to watch for changes within the directory, not to changes to the directory's attributes themselves.

The Windows operating system notifies your component of file changes in a buffer created by the FileSystemWatcher. If there are many changes in a short time, the buffer can overflow. This causes the component to lose track of changes in the directory, and it will only provide blanket notification. To avoid a buffer overflow you can filter out unwanted change notifications.

monitor.jpg

Using the code

You can download the attached source code to understand how to use this class, to monitor certain partitions on HDD or a specific location.

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Silviu Caragea

Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject.

He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy.

His programming experience includes:
- C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL)
- Open Source libraries :CURL & Boost
- HTML, CSS
- Java (SE,ME)
- JavaScript, Ajax, Google Web Toolkit (GWT)
- Php, MySQL
-Oracle, PL SQL
- C# .NET
-Objective C, IPhone SDK, Cocoa

Location: Romania
Ocupation: Software Engineer
Home page: http://www.intelliproject.net

Sign up to post message on the article message board!