Solved

How do you determine DIRECTORY size?

Posted on 1998-08-25
4
200 Views
Last Modified: 2008-03-04
My question is this:  How can I determine the size of a Directory?  Is there a simple function similar to Filelen(filepath)?  I don't want to scroll through all the files of a directory and add up all the filesizes.

Thanks!
0
Comment
Question by:ksm
  • 2
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
tuvi earned 50 total points
ID: 1960257
Sorry, there is no such function. Even the Windows API don't have it. You have to do the FileSearch which returns the total number of files then do the loop and add the size up. It's not much code at all.
0
 

Author Comment

by:ksm
ID: 1960258
Can you give me an example of the filesearch routine?
0
 
LVL 5

Expert Comment

by:tuvi
ID: 1960259
Dim fCount As Long
Dim lngSize As Long

lngSize = 0
With Application.FileSearch
  .FileName = "*.*"
  .LookIn = "C:\" ' or whatever directory
  .SearchSubFolders = True including sub-folders
  If .Execute > 0 Then
    For fCount = 1 To .FoundFiles.Count  
      lngSize = lngSize + FileLen(.FoundFiles(fCount))
    Next fCount
  End If
End With

' lngSize is the size of your directory in bytes
0
 

Author Comment

by:ksm
ID: 1960260
Excellent.  Thanks.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question