Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

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

Folder exists


Private Function DirExists(DirectoryName As String ) As Boolean
   DirExists = (Dir$(DirectoryName, vbDirectory) <> "" )
End Function

'=======================
If Len(Dir( "c:\foldername" , vbDirectory)) <> 0 Then
  'directory exists
End If

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

'folder exists
If fso.FolderExists( "C:\Files" ) Then
   MsgBox "Folder Exists!"
End If