This documentation is archived and is not being maintained.

FileSystemWatcher.IncludeSubdirectories Property

Gets or sets a value indicating whether subdirectories within the specified path should be monitored.

[Visual Basic]
Public Property IncludeSubdirectories As Boolean
public bool IncludeSubdirectories {get; set;}
public: __property bool get_IncludeSubdirectories();
public: __property void set_IncludeSubdirectories(bool);
public function get IncludeSubdirectories() : Boolean;
public function set IncludeSubdirectories(Boolean);

Property Value

true if you want to monitor subdirectories; otherwise, false. The default is false.


Set IncludeSubdirectories to true when you want to watch for change notifications for files and directories contained within the directory specified through the Path property, and its subdirectories. Setting the IncludeSubdirectories property to false helps reduce the number of notifications sent to the internal buffer. For more information on filtering out unwanted notifications, see the NotifyFilter, and InternalBufferSize properties.

When true, IncludeSubdirectories is recursive through the entire sub tree, not just the immediate child directories. The relative path to a file or directory within the sub tree returns in the Name property of FileSystemEventArgs and the OldName property of RenamedEventArgs, depending on changes you are watching for. You can get the fully qualified path from the FullPath property of FileSystemEventArgs and the OldFullPath property of RenamedEventArgs, depending on the changes you are watching for.

If a directory is created in the sub tree of the directory you are watching, and IncludeSubdirectories is true, that directory will automatically be watched.


Platforms: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

FileSystemWatcher Class | FileSystemWatcher Members | System.IO Namespace | NotifyFilter | FileSystemEventArgs | Filter | FileSystemEventArgs.FullPath | RenamedEventArgs.OldFullPath | InternalBufferSize | FileSystemEventArgs.Name | RenamedEventArgs.OldName | Path | RenamedEventArgs