Solved

How do you determine DIRECTORY size?

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

910 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

16 Experts available now in Live!

Get 1:1 Help Now