FileSystemEventArgs.Name 属性

定义

获取受影响的文件名或目录名。Gets the name of the affected file or directory.

public:
 property System::String ^ Name { System::String ^ get(); };
public string? Name { get; }
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String

属性值

String

受影响的文件名或目录名。The name of the affected file or directory.

注解

属性返回的名称 Name 是受影响的文件或目录的相对路径,与受监视的目录有关。The name returned by the Name property is the relative path of the affected file or directory, with respect to the directory being watched. 例如,如果 FileSystemWatcher 对象正在监视目录 "C:\temp",而 "C:\temp\test\file.txt" 的文件发生更改,则 Name 属性将返回 "test\file.txt"。For example, if a FileSystemWatcher object is watching the directory "C:\temp" and the file at "C:\temp\test\file.txt" changes, the Name property will return "test\file.txt".

Name如果重命名的事件 FileSystemWatcher 不能从操作系统中获得匹配的新旧名称事件,则该属性可能为 null。The Name property may be null for renamed events if the FileSystemWatcher does not get matching old and new name events from the OS.

适用于