Public Function GetFolderSize(ByVal path As String, _
ByVal includeSubFolders As Boolean) As Long
GetFolderSize = 0
Dim main_dir As New System.IO.DirectoryInfo(path)
Dim dir_files() As FileInfo
If includeSubFolders Then
dir_files = main_dir.GetFiles("*", SearchOption.AllDirectories)
Else
dir_files = main_dir.GetFiles("*", SearchOption.TopDirectoryOnly)
End If
For Each ofile As IO.FileInfo In dir_files
GetFolderSize = GetFolderSize + ofile.Length
Next
End Function
"I have not failed. I've just found 10,000 ways that won't work."
--Thomas Edison
"Not everything that can be counted counts, and not everything that counts can be counted."
--Albert Einstein
"If you can't make it good, at least make it look good."
"Your most unhappy customers are your greatest source of learning."
--Bill Gates
No comments:
Post a Comment