'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
    Debug.Print y.DriveType
    If y.DriveType = Fixed Then
       Debug.Print "AvailableSpace: " & y.AvailableSpace / 1024 / 1024 & " MBytes"
       Debug.Print "DriveLetter: " & y.DriveLetter
       Debug.Print "DriveType: " & y.DriveType
       Debug.Print "FileSystem: " & y.FileSystem
       Debug.Print "FreeSpace: " & y.FreeSpace / 1024 / 1024 & " MBytes"
       Debug.Print "IsReady: " & y.IsReady
       Debug.Print "Path: " & y.Path
       Debug.Print "RootFolder: " & y.RootFolder
       Debug.Print "SerialNumber: " & y.SerialNumber
       Debug.Print "ShareName: " & y.ShareName
       Debug.Print "TotalSize: " & y.TotalSize / 1024 / 1024 & " MBytes"
       Debug.Print "VolumeName: " & y.VolumeName
    End If
Next

解决方案 »

  1.   

    当然,这里存在一个计算问题,Windows中的磁盘属性获得的空间是不准确的。
      

  2.   

    playyuer:你好我用了一下发现totalsize和freesize计算的值是一样的,按道理两个是不相等的另外我想问一下在VB中如何计算文件的大小
      

  3.   

    GetDiskFreeSpace
    在采用FAT16格式的windows95系统中,如一个驱动器(分区)的容量超过了2GB,则不应使用这个函数。此时,这个函数能识别的最大分区容量只有2GB
      

  4.   

    AvailableSpace = FreeSpace << TotalSizeDebug.Print FileLen("..\..\xxx")
      

  5.   

    用fso也可以啊,不过我没有计算过,不知道计算出来的正不正确,还有硬盘的格式也有关系,有些文件的大小和实际占用的磁盘控件是不一样的