Micro Focus QTP (UFT) Forums

Full Version: How to delte multiple file?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Code:
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

if fso.fileExists("C:\Folder1\Folder2\file.doc")Then

fso.DeleteFile("C:\Folder1\Folder2\file.doc")
End if

with the help of above code i am able to delete a particular file in a folder.
But suppose in folder2 there are 3-4 doc file with different name and i want to delete them what should i do for this?
Hello here is a script I wrote to remove all the files from a Folder (I hope it helps):

Code:
Set fso=CreateObject("Scripting.FileSystemObject")
CleanPath="C:\Jon_Test_Folder\DeleteFiles\"
FileCount=0
    For Each file In fso.GetFolder(CleanPath).Files
        FileCount=FileCount+1
        Reporter.ReportEvent micDone, "File_Deleted", " '"&File&"': was deleted "
        file.delete
    Next
Reporter.ReportEvent micDone, "Files_Deleted", " There where '"&FileCount&"' Files deleted from '"&CleanPath&"' "