Sub SizeOfFilesInFolder(f As String) As Long
Dim total As Long
For Each filename As String In File.ListFiles(f)
If File.IsDirectory(f, filename) = False Then
total = total + File.Size(f, filename)
End If
Next
Return total
End Sub
Sub SizeOfFilesInFolder(f As String) As Long
Dim total As Long
For Each filename As String In File.ListFiles(f)
If File.IsDirectory(f, filename) = False Then
total = total + File.Size(f, filename)
Else
total = total + SizeOfFilesInFolder(f&"\"&filename)
End If
Next
Return total
End Sub
The reason that I didn't implement the recursive solution is that there are a few pitfalls. Whether they are relevant or not depends on your app requirements:
1. It can be slow if you choose a folder such as the root folder.
2. On Linux there might be symbolic links that can cause the recursive function to never end (until the stack is overflowed).
Another option is to let the OS calculate it for you.
Depending on the OS you could shell to commands like "dir <myfolder> /a /s" or "du -sh <folder.." or similar, then parse the result.