Pages

Wednesday, 19 October 2011

QTP Script: Delete a local or network file.


' ============================================================= 
' function: FileDelete 
' desc : Deletes a file 
' params : strFile - full path of the file to delete 
' returns : void 
' ============================================================= 
Function FileDelete(strFile, strTarget) 

Dim objFS 

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

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

    ' fail if the source does not exist 
    reporter.ReportEvent micFail, "Delete File""Unable to Delete the File '"& strFile &"', It Does Not Exist" 

Else 

    ' delete the file 
    objFS.DeleteFile strFile 

End If 

' destroy the object 
Set objFS = Nothing 

End Function 'FileDelete 


0 comments:

Post a Comment