Directory sizes 
Author Message
 Directory sizes

How can I determine the size of directories contents?

Plz?

Jn skar Magnsson



Sat, 23 Dec 2000 03:00:00 GMT  
 Directory sizes
You could use the DIR function to get all the files in the directory, and
then use the FILELEN function to find the size of each and add it up.

This example should work, but I haven't tested it.

Dim strFile As String, lngSize As Long
strFile = Dir("C:\Windows\*.*")
Do Until strFile = ""
    lngSize = FileLen("C:\Windows\" & strFile) + lngSize
    strfile = Dir()
Loop

Quote:

>How can I determine the size of directories contents?

>Plz?

>Jn skar Magnsson




Sun, 24 Dec 2000 03:00:00 GMT  
 Directory sizes
On Wed, 8 Jul 1998 13:12:18 -0230, "Jason Bouzane"

Sadly, this won't work at all. There are two problems with this code:

* The Dir call is made outside the loop, so the loop will measure the
same file again and again, until you get an overflow error.

* This code doesn't take into account the subdirectories in the
folder, so even if it worked, it wouldn't be of much use.

What you need is a recursive subroutine, one that calls itself for
every subfolder. I've been putting it off, but I see this kind of
question again and again in this NG, and that I must create one and
post for your benefit -- unless somebody beats me to it.

//K.

Quote:
>You could use the DIR function to get all the files in the directory, and
>then use the FILELEN function to find the size of each and add it up.

>This example should work, but I haven't tested it.

>Dim strFile As String, lngSize As Long
>strFile = Dir("C:\Windows\*.*")
>Do Until strFile = ""
>    lngSize = FileLen("C:\Windows\" & strFile) + lngSize
>    strfile = Dir()
>Loop


>>How can I determine the size of directories contents?

>>Plz?

>>Jn skar Magnsson




Fri, 29 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Find file and directory size...

2. FileSystemWatcher Path / Directory size

3. How do you get directory size in vb.net

4. getting directory size

5. Please tell me how to find a directory size

6. Directory size in bytes

7. getting directory size in vb

8. Directory size?

9. Directory size?

10. counting directory size

11. How do you determine DIRECTORY size?

12. Directory Size?

 

 
Powered by phpBB® Forum Software