Micro Focus QTP (UFT) Forums
How to delte multiple file? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to delte multiple file? (/Thread-How-to-delte-multiple-file)



How to delte multiple file? - Anug - 05-20-2009

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?


RE: How to delte multiple file? - Jackomcnabb - 05-20-2009

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&"' "