Solved

How do you determine DIRECTORY size?

Posted on 1998-08-25
4
203 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access / SQL Server - ODBC Problems 16 59
Microsoft Access VBA - allocate a colour 3 74
How to get data off Lotus Notes server 4 74
Using a combo box to search a form. 3 36
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

739 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