You can use this function to return the size of a specific folder:
Public Function FldrSize(ByVal dPath As String)
Dim size As Long = 0
For Each foundFile As String In My.Computer.FileSystem.GetFiles(dPath, FileIO.SearchOption.SearchAllSubDirectories, “*.*”)
Dim fInfo As New FileInfo(foundFile)
size += fInfo.Length
Next
Return size
End Function
This returns the number of bytes in the folder. I then feed that result to code found here to view that as megabtyes or gigabytes.
This function returns the total size of a drive and the free space of the specified drive:
Private Function GetSize(ByVal drive As String)
Dim parameter As String = “win32_logicaldisk.deviceid=””” + drive + “:”””
Dim diskSize As New ManagementObject(parameter)
Dim detailsString As String = “”
diskSize.Get()
detailsString = “Disk Space in ” + drive + ” is :” & diskSize(“Size”).ToString
detailsString = detailsString & vbCrLf & “<br>Free space in ” + drive + ” is :” & diskSize(“FreeSpace”).ToString
Return detailsString
End Function
Again, this returns the bytes and I use code found here to convert that to megabytes or gigabytes.