1 2 3 | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.AllowDrop = True End Sub |
1 2 3 4 5 6 7 8 9 10 | Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop 'Dim file As String = e.Data.GetData(DataFormats.FileDrop)(0) 'If Path.GetExtension(file).ToLower = ".mp4" Then ' MsgBox(file) 'End If Dim files() As String = e.Data.GetData(DataFormats.FileDrop) For Each path In files MsgBox(path) Next End Sub |
1 2 3 4 5 6 7 8 9 10 11 | Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter If e.Data.GetDataPresent(DataFormats.FileDrop) Then Dim file As String = e.Data.GetData(DataFormats.FileDrop)(0) Dim strExtension As String = Replace(Path.GetExtension(file).ToLower, ".", "") If strExtension = "mp4" Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.None End If End If End Sub |
沒有留言:
張貼留言