Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting count of the toral nos. files present inside a folder in Win7
#1
Solved: 11 Years, 4 Months, 4 Weeks ago Rolleyes 
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
Reply
#2
Solved: 11 Years, 4 Months, 4 Weeks ago
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
Reply
#3
Solved: 11 Years, 4 Months, 4 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Executing via create "RES"xx folder? nishitd 0 1,292 03-07-2018, 01:09 AM
Last Post: nishitd
  Set Value in JavaEdit Inside JavaTable yonobev 9 13,121 11-08-2017, 11:12 PM
Last Post: lotos
  Objects inside WpfList shinji458 23 22,421 11-08-2017, 10:54 PM
Last Post: lotos
  code for validation to create a sub folder smiley 0 1,565 10-19-2016, 10:08 PM
Last Post: smiley
  Get numbers inside all webelements in webtable and sort them pradeep537 1 2,850 08-04-2016, 01:24 AM
Last Post: Ankur

Forum Jump:


Users browsing this thread: 1 Guest(s)