Gets or sets the path string of the directory to watch.
[Visual Basic] Overridable Public Property Path As String [C#] public string Path {virtual get; virtual set;} [C++] public: __property virtual String* get_Path(); public: __property virtual void set_Path(String*); [JScript] public function get Path() : String; public function set Path(String);
The path to monitor. The default is an empty string ("").
This is a fully qualified path to a directory. The directory is the root at which the system will listen to notifications. To watch a specific file, set the Path property to the correct directory, and the Filter property to the filename.
The Path property supports Universal Naming Convention paths.
Note This property must be set before the component can start watching for changes.
When a directory is renamed, the FileSystemWatcher will automatically "reattach" itself to the newly renamed item. For example, if you set the Path property to "c:\My Documents" and then manually rename the directory to "c:\Your Documents", the component will continue to listen for change notifications on the newly renamed directory. However, when you ask for the Path property, it will contain the old path. This happens because the component determines what directory it is watching based on the handle, rather than the name of the directory. Renaming does not affect the handle. So, if you destroy the component, and then recreate it without updating the Path property, your application will fail because the directory no longer exists.
FileSystemWatcher Class | FileSystemWatcher Members | System.IO Namespace | FileSystemWatcher | Filter