FileSystemObject.FileExists Method (VB6)

Named Arguments

Yes

Syntax

oFileSysObj.FileExists(FileSpec)

oFileSysObj

Use: Required

Data Type: FileSystemObject object

Any object variable returning a FileSystemObject object.

FileSpec

Use: Required

Data Type: String

A complete path to the file.

Return Value

Boolean (True or False).

Description

Determines if a given file exists.

Rules at a Glance

  • Returns True if the file exists or is connected to the machine, False if not.

  • FileSpec can't contain wildcard characters.

Programming Tips and Gotchas

If the user has adequate rights, FileSpec can be a network path or share name. For example:

If ofs.FileExists("\\TestPath\Test.txt") Then
						
						

Get VB & VBA in a Nutshell: The Language 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.