Path.Exists(String) 方法

定义

确定指定的文件或目录是否存在。

public:
 static bool Exists(System::String ^ path);
public static bool Exists(string? path);
static member Exists : string -> bool
Public Shared Function Exists (path As String) As Boolean

参数

path
String

要检查的路径

返回

true 如果调用方具有所需的权限并 path 包含现有文件或目录的名称,则为 ;否则为 false。 此方法还返回false无效path路径或零长度字符串。null 如果调用方没有足够的权限读取指定路径,则不会引发异常,并且该方法将返回 false 而不考虑是否存在 path

注解

与此方法不同 Exists(String),此方法返回 true 现有非常规文件(如管道)。 如果路径以现有链接为目标,但链接的目标不存在,则返回 true

适用于