Share via


Exists Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Determines whether the given path refers to an existing directory on disk.

Namespace:  System.IO
Assembly:  System.IO (in System.IO.dll)

Syntax

'Declaration
Public Shared Function Exists ( _
    path As String _
) As Boolean
public static bool Exists(
    string path
)
public:
static bool Exists(
    String^ path
)
static member Exists : 
        path:string -> bool 
public static function Exists(
    path : String
) : boolean

Parameters

Return Value

Type: System. . :: . .Boolean
true if path refers to an existing directory; otherwise, false.

Remarks

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 Exists method will return false.

The Exists 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.

.NET Framework Security

See Also

Reference

Directory Class

System.IO Namespace