Share via


Exists Property

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

Gets a value indicating whether a file exists.

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

Syntax

'Declaration
Public Overrides ReadOnly Property Exists As Boolean
public override bool Exists { get; }
public:
virtual property bool Exists {
    bool get () override;
}
abstract Exists : bool with get
override Exists : bool with get
override function get Exists () : boolean

Property Value

Type: System. . :: . .Boolean
true if the file exists; false if the file does not exist or if the file is a directory.

Remarks

When first called, FileInfo calls Refresh and caches information about the file. On subsequent calls, you must call Refresh to get the latest copy of the information.

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.

.NET Framework Security

See Also

Reference

FileInfo Class

System.IO Namespace