Size of a folder on disk.

  • Thread starter Thread starter Ty Moffett
  • Start date Start date
T

Ty Moffett

What is the best way to find the size of a folder (actually it's contents)
on a disk?
 
Ty Moffett said:
What is the best way to find the size of a folder (actually it's contents)
on a disk?

I converted the C# code...

Private Function DirSize(ByVal path As String) As Long

Dim sz As Long = 0
Dim d As DirectoryInfo = New DirectoryInfo(path)

' get file length
Dim f As FileInfo

For Each f In d.GetFiles()
sz += f.Length
Next

' recurse into directories
Dim dx As DirectoryInfo

For Each dx In d.GetDirectories()
sz += DirSize(dx.FullName)
Next

Return sz

End Function
 
Heh, just a I got it converted I noticed your post. At least I know I'm
learning something. Thanks fellas. =)
 
Back
Top