I\'m writing a "function" that returns a file\'s size (in B, KB, MB, GB).
The VB.Net code always gets the size in bytes first, so when a file\'s size (in Bytes)
Public Function GetDirSize(RootFolder As String) As Long
Dim FolderInfo = New IO.DirectoryInfo(RootFolder)
For Each File In FolderInfo.GetFiles : TotalSize += File.Length
Next
For Each SubFolderInfo In FolderInfo.GetDirectories : GetDirSize(SubFolderInfo.FullName)
Next
Return TotalSize
End Function
Public Sub GetfilesizeFromDirectory()
Dim path As String
path = "D:"
TotalSize = 0 'Reset the counter
Dim TheSize As Long = GetDirSize(path)
' TextBox1.Text = (FormatNumber(TheSize / 1024 / 1024 / 1) & vbCr & "MB")
End Sub