Solved

How do you determine DIRECTORY size?

Posted on 1998-08-25
4
197 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now