
Not the object will fire events when it receives a change notification. Important property of this object is the “ EnableRaisingEvents” property. The FileSystemWatcher basicsĪre a few basic properties and events you need to familiarize yourself with before working with the FileSystemWatcher object. You’re not constantly polling the directory for changes, and there is no time Notification of changes allows your system to work much more efficiently since This allows your program to know when a new file isĪvailable almost immediately after the file is created. When a file is created, updated, or deleted, the FileSystemWatcher fires an event to notify you that aĬhange has occurred. The FileSystemWatcher object does the work of monitoringĪ directory for you. Withįramework, Microsoft has provided developers with an alternative to constantly polling aĭirectory for new files–the FileSystemWatcher object. This type of functionality is accomplished by “polling” the directoryĪnd enumerating any new files that have been created since the last poll. Pick up the file, parse it, and insert it into the database. In this instance, a program must monitorĪ directory for newly created files. This article is also available as a TechRepublic download, which includes a complete Visual Studio 2005 project file with example code.Īre many instances that require systems to perform certain tasks when files orĭirectories are created or modified. Zach Smith explains how to use the FileSystemWatcher object and demonstrates it in a sample application. This object allows you to be notified when certain events occur in a directory, such as file creation, deletion, or modification. NET Framework class library is the System.IO.FileSystemWatcher.

One of the more interesting objects included in the Microsoft. NET FileSystemWatcher object to monitor directory changes in C#
