FileSystemWatcher.IncludeSubdirectories 属性
本文内容
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否应监视指定路径中的子目录。
public:
property bool IncludeSubdirectories { bool get(); void set(bool value); };
public bool IncludeSubdirectories { get; set; }
[System.IO.IODescription("FSW_IncludeSubdirectories")]
public bool IncludeSubdirectories { get; set; }
member this.IncludeSubdirectories : bool with get, set
[<System.IO.IODescription("FSW_IncludeSubdirectories")>]
member this.IncludeSubdirectories : bool with get, set
Public Property IncludeSubdirectories As Boolean
如果要监视子目录,则为 true
;否则为 false
。 默认值为 false
。
- 属性
true
如果要为通过 Path 属性指定的目录及其子目录中包含的文件和目录watch更改通知,请将 设置为 IncludeSubdirectories 。 将 IncludeSubdirectories 属性设置为 false
有助于减少发送到内部缓冲区的通知数。 有关筛选掉不需要的通知的详细信息,请参阅 NotifyFilter 和 InternalBufferSize 属性。
当 时 true
, IncludeSubdirectories 将在整个子树(而不仅仅是直接子目录)中递归。 子树中文件或目录的相对路径将在 的 FileSystemEventArgs 属性和 OldName 的 RenamedEventArgs属性中Name返回,具体取决于要监视的更改。 可以从 的 属性和 的 属性FileSystemEventArgs获取完全限定的路径FullPath,具体取决于要监视的RenamedEventArgs更改。OldFullPath
如果在正在监视的目录的子树中创建目录,并且 IncludeSubdirectories 为 true
,则会自动监视该目录。
产品 | 版本 |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |