Pages

Wednesday, 19 October 2011

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


' =============================================================
' function: CheckFileExists
' desc : Checks to see if a file exists
' params : strFile - full path of the file to find
' returns : True if file exists, False otherwise
' =============================================================

Function CheckFileExists(strFile)

 

Dim objFS

 

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

 

' check that the source file exists
If objFS.FileExists(strFile) Then

 

    ' file exists, return true
    CheckFileExists = True

Else 

    
' file exists, return false
    CheckFileExists = False

End If

End Function 'CheckFileExists


0 comments:

Post a Comment