Check if File Exists – Including Hidden Files

By | 2002-06-01

Simple function to check if file exists. Detects Normal & Hidden files. Improvement of code from Greg G., and incorporating a suggestion by Larry Rebich.

Original Author: Dan Redding – Blue Knot Software

Inputs

A Valid Pathname as String.

Returns

Boolean TRUE if file exists at path specified

Side Effects

Simply returns FALSE if an invalid path is encountered

Code

Public Function FileExists(strFile as String) As String
On Error Resume Next 'Doesn't raise error - FileExists will be false
      'if error occurs
'a valid path would be someting like "C:Windowswin.ini" - Full path
'must be specified
FileExists = Dir(strFile, vbHidden) <> ""

End Function

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.