Folder Size
-
I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?
-
I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?
Private Function DirectoryList(ByVal Name As String) As Int64 Dim Folder As New DirectoryInfo(Name) Dim SubFolder As DirectoryInfo Dim File As FileInfo Dim Size As Int64 = 0
'Get the size of all files in folder For Each File In Folder.GetFiles() Size += Files.Length Next
'Get the size of all subfolders in folder For Each SubFolder In Folder.GetDirectories() Size += DirectoryList(SubFolders.FullName) Next
MsgBox(Name & " containes " & Size & " bytes")
Return Size End Function -
I'm a vb.net noob who needs some help. Is there a way to get the size of a specified folder? I'm using this code to get all sub-directories of a specified folder and would like to also retrive the folder size of each. Dim myPath As String = "C:\test" Dim myDirectory As System.IO.Directory Dim mySubDirectory As String Dim myDirectorySize As String If myDirectory.Exists(myPath) Then For Each mySubDirectory In myDirectory.GetDirectories(myPath) MsgBox(mySubDirectory) Next End If Any ideas?
Sorry, I was a little quick there... A simple sollution would be to make a recursive function, like the one in the example in the preceding thread. The topmost folder will be displayed last...
-
Sorry, I was a little quick there... A simple sollution would be to make a recursive function, like the one in the example in the preceding thread. The topmost folder will be displayed last...