下边的代码是定位除A盘外的U盘或移动硬盘的位置,若不存在则定位程序所在的位置。
Private Sub Form_Load()
For Each drv In fso.Drives
If drv.DriveType = 1 And UCase(drv.DriveLetter) <> "A" Then
sDrvLetter = UCase(drv.DriveLetter)
Exit For
End If
Next drv
If sDrvLetter = "" Then
Drive1.Drive = App.Path
Else
Drive1.Drive = (sDrvLetter) & ":\"
End If
Dir1.Path = Drive1.Drive
sSavePath = Dir1.Path
Label1.Caption = sSavePath
End Sub