Micro Focus QTP (UFT) Forums
Getting count of the toral nos. files present inside a folder in Win7 - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Getting count of the toral nos. files present inside a folder in Win7 (/Thread-Getting-count-of-the-toral-nos-files-present-inside-a-folder-in-Win7)



Getting count of the toral nos. files present inside a folder in Win7 - arijitdhar - 07-15-2009

Hello,

I am using QTP 9.2 and I am trying to get the total number of files present inside a folder in Windows 7 OS.

In Windows Vista OS I am getting the count using "GetItemsCount" :
Code:
totalcount = Windows("Object").WinListView("SysListView32").GetItemsCount

Since, XP and Vista OS is recognizing any folder window as Class = WinListView

But, in Win7 OS QTP is recognizing the folder window as Class = WinObject, as a result I am unable to use GetItemCount in case of Win7 OS.

It will be nice if anyone can help me on this.

Thanks,
Arijit Dhar


RE: Getting count of the toral nos. files present inside a folder in Win7 - sreekanth chilam - 07-15-2009

Hi Arijith,

For this type of requirements only we do have FSO(File system object).
Go thru the help file for FSO & implement accordingly.

Anyhow i am giving you the below solution.

Code:
Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("give entire folder path here")
Set vFiles =colFolderName.Files
Sno=0
For each i in vFiles
d=Split(i,"\")
FileName=d(ubound(d))
Sno=Sno+1
msgbox "File "&Sno&" : "&FileName
Next

msgbox "Number of files in Current Folder : "&vFiles.count



RE: Getting count of the toral nos. files present inside a folder in Win7 - arijitdhar - 07-18-2009

Hi Sreekanth,

Thanks a lot for helping out. The solution you have provided is working fine in Windows 7.
I have also modified it a little bit to get count and names of the subfolders inside the given folder.

Thanks,
Arijit Dhar Smile