DirectoryInfo.Exists Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets a value indicating whether the directory exists.

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

override Exists : bool with get

Property Value

Type: System.Boolean

true if the directory exists; otherwise, false.

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

The following example demonstrates a use of the Exists property in the context of copying a source directory to a target directory.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 10
.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: