VB如何判断拖放的文件路径是否为磁盘根目录

来源:百度知道 编辑:UC知道 时间:2024/06/21 09:28:13
VB如何判断拖放的文件路径是否为磁盘根目录?

在拖放事件Private Sub xxxx_OLEDragDrop(Data As DataObject,……中
If Data.GetFormat(vbCFFiles) Then
Dim vFN
For Each vFN In Data.Files
MsgBox IIf(Mid$(vFN, InStrRev(vFN, "\") - 1, 1) = ":", "", "不") & "是根目录"
Next
End If

Private Sub Command1_Click()
s = RTrim(Text1.Text)
s = Right$(Replace(s, "\", vbNullString), 1)
If s = ":" Then
MsgBox "根目录"
Else
MsgBox "非根目录"
End If
End Sub