Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Returning folders total from a drive(s)
Message
 
 
To
11/10/2001 05:19:32
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00566830
Message ID:
00566974
Views:
28
>Hi
>
>Could anyone advise how to return the total number of folders that exists on a drive(s).
>
>It's for use in a progressbar calculation for a file search .prg
>
>TIA
>
>Dennis

Dennis,
You would have to build a recursive routine that used the Scripting.Filesystemobject object to drill down into your drive. Create following as procedure or program GetFolderCount:
lparameter tcdir
local ofso as Scripting.FileSystemObject, ofolder as Scripting.Folder, oFoldertmp as Scripting.Folder
local lncount
lncount = 0
ofso = createobject('scripting.filesystemobject')
ofolder = ofso.GetFolder(tcdir)
for each oFoldertmp in oFolder.SubFolders
   lncount = lncount + GetFolderCount(oFoldertmp.Path)
endfor
lncount = lncount + ofolder.SubFolders.Count

return lncount
And like George said, this could take awhile given that you could have a very large hard drive.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform