The following function is used to calculate the number of bytes occupied by a file directory:
The REM function returns the number of bytes occupied by the directory.
Function DirUsedBytes(ByVal dirName As String) As Long
Dim FileName As String
Dim FileSize As Currency
If Right$(dirName, 1) <> / Then
dirName = dirName & /
Endif
FileSize = 0
FileName = Dir$(dirName & *.*)
Do While FileName <>
FileSize = FileSize + FileLen(dirName & FileName)
FileName = Dir$
Loop
DirUsedBytes = FileSize
end function
How to use:
MsgBox DirUsedBytes(D:/musics)