Name

File.Exists Method

Class

System.IO.File

Syntax

File.Exists(path)
path (required; String)

The file path

Return Value

A Boolean indicating whether the file exists

Description

Indicates whether a file exists

Rules at a Glance

  • path is a fully qualified filename or a relative path (which is interpreted as starting in the current directory).

  • The Exists method returns True only if the specified file exists; otherwise, it returns False. Note that Exists returns False if path describes a directory instead of a folder.

Programming Tips and Gotchas

Since the File class is shared, you don’t have to instantiate any objects before calling the File.Exists method.

Get VB.NET Language in a Nutshell, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.