Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

File exists


Function FileExists(filename) As Boolean
If Dir(filename) <> "" Then FileExists = True   
End If

'=======================
'alternate approach using FileSystemObject (add reference to project to use)
Dim fso As New FileSystemObject

'file exists
If fso.FileExists( "C:\Files\file.txt" ) Then
   MsgBox "File Exists!"
End If