file or folder exists





-2
Date Submitted Thu. Mar. 2nd, 2006 5:03 AM
Revision 1 of 1
Syntax Master dannyboy
Tags exists | File | Folder | VBSCRIPT
Comments 0 comments

Checks to see if a file or folder exists
The fFile variable determines whether you're
looking for a File (True) or Folder(False)
The strName variable holds the fully qualified
path you're looking For

Function CheckFileFolderExists(strName, fFile)


Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
  CheckFileFolderExists = False
 
  If fFile = True Then  ' It's a file

    If fso.FileExists(strName) = True Then
      CheckFileFolderExists = True
      Exit Function
    End If

  Else  ' It's a folder/directory

    If fso.FolderExists(strName) = True Then
      CheckFileFolderExists = True
      Exit Function
    End If

  End If
 
  Set fso = Nothing

End Function

 

Comments

There are currently no comments for this snippet.

Voting