true if path refers to an existing directory; false if the directory does not exist or an error occurs when trying to determine if the specified file exists.
true if path refers to an existing directory; otherwise, false.
Type Reason ArgumentException path is a zero-length string, contains only white space, or contains one or more implementation-defined invalid characters. System.IO.PathTooLongException The length of path or the absolute path information for path exceeds the system-defined maximum length. System.IO.DirectoryNotFoundException path was not found.
The path parameter is permitted to specify relative or absolute path information. Relative path information is interpreted as relative to the current working directory.
Trailing spaces are removed from the end of the path parameter before checking whether the directory exists.
The path parameter is not case-sensitive.
If you do not have at a minimum read-only permission to the directory, the Directory.Exists(string) method will return false.
The Directory.Exists(string) method returns false if any error occurs while trying to determine if the specified file exists. This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, a failing or missing disk, or if the caller does not have permission to read the file.
Type | Reason |
---|---|
System.Security.Permissions.FileIOPermission | Requires permission to read the specified directory. See System.Security.Permissions.FileIOPermissionAccess.Read. |