Path.Exists(String) Method

Definition

Determines whether the specified file or directory exists.

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

Parameters

path
String

The path to check

Returns

true if the caller has the required permissions and path contains the name of an existing file or directory; otherwise, false. This method also returns false if path is null, an invalid path, or a zero-length string. If the caller does not have sufficient permissions to read the specified path, no exception is thrown and the method returns false regardless of the existence of path.

Remarks

Unlike Exists(String), this method returns true for existing, non-regular files like pipes. If the path targets an existing link, but the target of the link does not exist, it returns true.

Applies to