Pages

Wednesday, 19 October 2011

QTP Script: Check to see if a local or network folder exists


' =============================================================
' function: CheckFolderExists
' desc : Checks to see if a folder exists
' params : strFolder - full path of the folder to find
' returns : True if folder exists, False otherwise
' =============================================================

Function CheckFolderExists(strFile)

 

Dim objFS

 

' create a file system object
Set objFS = CreateObject("Scripting.FileSystemObject")

 

' check that the source file exists
If objFS.FolderExists(strFolder) Then

 

    ' file exists, return true
    CheckFolderExists = True

Else

    ' file exists, return false
    CheckFolderExists = False

End If

 

' destroy the object
Set objFS = Nothing

End Function
 'CheckFolderExists


0 comments:

Post a Comment