Private Function GetFileSize(ByVal MyFilePath As String) As Long Dim MyFile As New FileInfo(MyFilePath) Dim FileSize As Long = MyFile.Length Return FileSize End Function Public Function GetFreeSpace(ByVal Drive As String) As Long Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long Dim iAns As Long iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, lBytesTotal, lFreeBytes) If iAns > 0 Then Return BytesToMegabytes(lFreeBytes) Else Throw New Exception("Invalid or unreadable drive") End If End Function Public Function GetTotalSpace(ByVal Drive As String) As String Dim lBytesTotal, lFreeBytes, lFreeBytesAvailable As Long Dim iAns As Long iAns = GetDiskFreeSpaceEx(Drive, lFreeBytesAvailable, _ lBytesTotal, lFreeBytes) If iAns > 0 Then Return BytesToMegabytes(lBytesTotal) Else Throw New Exception("Invalid or unreadable drive") End If End Function
Last Updated on September 2, 2019