以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  怎么读电脑最后一个硬盘盘符  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=47282)

--  作者:temblar
--  发布时间:2014/3/7 15:47:00
--  怎么读电脑最后一个硬盘盘符

 

怎么读取电脑最后一个硬盘分区的盘符?一定是硬盘 不含光驱。下面是我曲线救国的代码,求正解

 

Dim pan As String
Dim MyPath() As String = {"c:\\","d:\\","e:\\","f:\\","g:\\","h:\\"}
Dim MyFolder As String
For i As Integer = 0 To 5
    try
        MyFolder = Dir(mypath(i) & "*.*", vbDirectory)
        If MyFolder <> "" Then
            pan = mypath(i)
        End If
    Catch ex As Exception
        pan = mypath(i-1)
    End Try
Next
Output.Show(pan)

--  作者:Bin
--  发布时间:2014/3/7 15:58:00
--  
Dim ds() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()
For i As Integer = 0 To ds.Length - 1
ds(i).DriveType.ToString \'驱动器类型
ds(i).Name \'盘符(驱动器名)
ds(i).IsReady.ToString \'是否就绪
If ds(i).IsReady = True Then
ds(i).VolumeLabel \'卷标
ds(i).TotalSize.ToString \'驱动器容量
ds(i).TotalFreeSpace.ToString \'驱动器可用容量
End If

Next