[VB.Net]讀取拖曳檔案的路徑
轉貼文章:六度空間
http://jeremy.tfeng.org/?p=502此程式碼可讀取到使用者拖曳到視窗裡的檔案路徑
請開啟一個Windows Form 後,分別在以下事件加入程式碼:
(Form1_Load,Form1_DragDrop,Form1_DragEnter)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.AllowDrop = True End Sub Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop Dim DragFilePath As String = CType(e.Data.GetData("FileNameW"), Array).GetValue(0) MsgBox(DragFilePath) End Sub Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter e.Effect = DragDropEffects.All End Sub
Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
e.Effect = DragDropEffects.All
End Sub
留言
張貼留言