
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
736
|
Chapter 12: Filesystem I/O
Discussion
Watching for changes in the filesystem centers around the FileSystemWatcher class.
This class can watch for filesystem changes on the local machine, a networked drive,
and even a remote machine. The limitations of watching files on a remote machine
are that the watching machine must be running versions of Windows starting from
Windows NT 4.0 through 2000, XP, Server 2003, and Windows Vista. The one
caveat for Windows NT 4.0 is that a Windows NT 4.0 machine cannot watch
another remote Windows NT 4.0 machine.
The
FileSystemWatcher object cannot watch directories or files on a CD or DVD
drive (including rewritables) in the current versions of the Framework. This limita-
tion might be revisited in a future version. This object does watch files regardless of
whether their hidden property is set.
To start watching a filesystem, we need to create an instance of the
FileSystem-
Watcher
class. After creating the FileSystemWatcher object, we can set its properties in
order to focus our efforts in watching a filesystem. Table 12-10 examines the various
properties that can be set on this object.
Table 12-10. Properties that can be set on the FileSystemWatcher object
Property name Description
Path A path to a directory to watch. The following are some examples ...