|
|
How Do I...Watch file system changes?Use the FileSystemWatcher component to monitor a file system and react when changes to it occur. This makes it possible for you to quickly and easily launch business processes when certain files or directories are created, modified, or deleted. For example, suppose you and a group of coworkers are collaborating on a document that is stored on a shared directory on your server. Using the FileSystemWatcher component, you can easily program your application to watch for changes to the shared directory. When a change is detected, the component can run processing that notifies each of the group members through email. This sample illustrates how to use a FileSystemWatcher to watch for any changes, renaming, creation, and deletion of any files in the specified directory. The application takes the directory that you wish to watch as the only argument. Try running the sample as follows: > Watcher.exe c:\ Now, open the c:\ directory and try creating, modifying and deleting a file in the directory. Observe the sample application printing an appropriate message to the console window. In its simplest form, using a FileSystemWatcher involves:
Example
|