注册 登录
编程论坛 VB.NET论坛

如何获取磁盘类型及空间使用情况?

梦幻倩影 发布于 2016-10-30 15:47, 1986 次点击
做关于表单时,经常会显示系统所在磁盘空间大小等信息
如何获取磁盘类型及空间使用情况?
        Imports scripting


        Dim fso As New FileSystemObject
        Dim drv1 As Drive
        Dim str1 As String
        drv1 = fso.GetDrive("c:\")
        str1 = "驱动器:" & "C:\" & vbCrLf
        str1 += "文件系统:" & drv1.FileSystem & vbCrLf
        str1 += "磁盘类型:" & drv1.DriveType & vbCrLf
        str1 += "磁盘容量:" & FormatNumber(drv1.TotalSize / 1024, 0) & "KB" & vbCrLf
        str1 += "可用空间:" & FormatNumber(drv1.FreeSpace / 1024, 0) & "KB" & vbCrLf
        str1 += "已用空间:" & FormatNumber(drv1.TotalSize / 1024 - drv1.FreeSpace / 1024, 0) & "KB" & vbCrLf
        Me.Label1.Text = str1
0 回复
1