Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Folder Size

Status
Not open for further replies.

CFB

Programmer
Jan 11, 2001
74
US
I'm trying to determine the size of a directory including all subdirectories and files contained within. Does anyone know of another way to obtain a directory's size besides creating a Folder Object with FileSystemObject? Thanks for the help.
 
Any ideas on this one? Using the FileSystemObject works well during my testing, but it seems to fail randomly during runtime. I've looked into using the SHGetFileInfo API call, but haven't been successful in working that out. I've searched high and low for other solutions, but haven't found anything. Thanks in advance.
 
use adir and recurse through the directories. Adir will return the sizes of the files and the names of any subdirectories. It should not be too difficult to write code to add the file sizes and then look at each subdirectory etc.

 
I think that's the way I'm going to have to go. I've written code to do that, but was looking for a quicker way to determine a larger directory's size. Thanks for the help.
 
Hi CFB,

You can cut and paste the following.. and suitable create your function to return the total size..
**********************************************************
*** Instantiate the Filer object
oMyFiler = CREATEOBJECT('Filer.FileUtil')
oMyFiler.SearchPath = 'E:\WINNERS\CMP' && Search Directory
oMyFiler.SubFolder = 1 && includes sub folders
oMyFiler.Find(1) && cumulate sub-folders
LOCAL nSize
nSize = 0
FOR nFileCount = 1 TO oMyFiler.Files.Count
nSize=nSize+oMyFiler.Files.Item(nFileCount).Size && add the size
ENDFOR
? nSize, oMyFiler.Files.Count && display size and count
***********************************************************
Hope this helps you :) ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top