【发布时间】:2012-11-10 19:35:03
【问题描述】:
当用户删除文件夹或文件时,我正在尝试区分,但出现错误。
更新
错误是:
Conversion from string "C:\Users\Administrador\Desktop\W" to type 'Long' is not valid.
(注意路径,不完整)
IDE 突出显示此错误行:
If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
我不知道问题是在转换还是什么,但是如果我在有问题的错误行之前使用 msgbox,我可以看到路径是正确的:
MessageBox.Show(Objetos(0))
If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
这是潜艇:
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
Dim attributes = Objetos(0)
If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
MsgBox("it's a dir")
Else
MsgBox("it's a file")
End If
foldertextbox.Text = Objetos(0)
userSelectedFolderPath = Objetos(0)
My.Settings.folderpath = Objetos(0)
My.Settings.Save()
playerargs = Nothing
updatecheckboxes()
End If
End Sub
【问题讨论】:
-
什么“错误”?你得到一个异常或者它不识别目录(总是作为“文件”)?
-
抱歉,感谢您的评论,我已经更新了我的问题
标签: vb.net visual-studio drag-and-drop