Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NUMBER OF FILES IN A DIRECTORY
Message
From
10/03/2000 11:27:40
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00344120
Message ID:
00344249
Views:
37
>Hi Larry,
>>
>>>> Does anyone know the command for finding out the total number of a directory ? Thanks.
>>>
>>>ADir() will work but Ed's enthusiasm has infected most of us. You could use the Scripting.FileSystemObject.
>>>
oFS = createobject("scripting.FileSystemObject")
>>>oFolder = oFS.GetFolder("\")
>>>return oFolder.Files.Count+oFolder.SubFolders.Count
>>>
>>>This will return the number of files and subdirectories in the specified directory.
>>
>>How can I find help about all properties and methods of scripting.FileSystemObject
>>
>>I used your program and it returns 9, 5 Files and 4 SubFolders. Now I'm trying to understand, which folder it used, how can I specify parameters, which folder to look and how can I print all file names in this directory and subfolders too.
>
>Ok, I can pass a parameter. Now I'm wondering, how can I count the number of files in all subfolders (not the number of subfolders). Right now it returns number of files in specified folder+ number of subfolders. If there a way to receive a number of all files in one command or I need to use recursion and calculate by myself.
>
>TIA


Nadya,
Think of time needed to collect all that info. Recursion is one of the answers but it might be the trap too if not done correctly. If directory depth goes over allowed nested calls than you're likely to get an error with recursion. Better instead of checking all at once, look when needed. Also with FSO be carefull it accesses to special folders too. One of these special folders is important that you shouldn't further attempt to get subfolders ("System Volume Information"). What that directory is a mystery to me. For FSO reference and a sample code search jscript5.chm on your MSDN. Also do a search for FSO and you'd find some code using it the way you want (months ago so Jan 1,1999-Jul 1,1999 is a near bet:).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform