拖放文件到文件夹 [英] Drag and Drop file move to folder

查看:90
本文介绍了拖放文件到文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我想通过拖放将zip文件移动到指定的文件夹,例如


Hi !
i want to move a zip with drag and drop to the specified folder like this


Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
     If File drop Then
         Dim path As String = "D:/pictures"
         Move file to path
     Else
     End If
 End Sub



当我将文件拖到panel1并将其拖放到文件D:/pictures
我如何制作此代码?
TNX寻求帮助!



when i drag file to panel1 and drop it the file move automatcly to folder D:/pictures
How i can make this code ?
TNX for help !

推荐答案

请参考以下链接.希望对您有所帮助.

http://www.codeproject.com/KB/tree/DragDropTreeview.aspx

http://www.codeproject.com/KB/shell/explorerdragdrop.aspx

http://www.codeproject.com/KB/dialog/JibDragDrop.aspx

http://www.codeproject.com/KB/clipboard/dragdropinterface.aspx
Refer the following links.I hope it will help you.

http://www.codeproject.com/KB/tree/DragDropTreeview.aspx

http://www.codeproject.com/KB/shell/explorerdragdrop.aspx

http://www.codeproject.com/KB/dialog/JibDragDrop.aspx

http://www.codeproject.com/KB/clipboard/dragdropinterface.aspx


类似的东西应该起作用
注意:在此示例中,我使用了Form,但是对于Panel来说将是相同的,只是确保将Panel的AllowDrop属性设置为true.
Something like this should work
Note: I used the Form in this example but will be the same for a Panel just make sure the AllowDrop property of you Panel is set to true.
Private Sub Form1_DragEnter(sender As Object, e As DragEventArgs) Handles MyBase.DragEnter
    If e.Data.GetDataPresent(DataFormats.FileDrop) Then
        e.Effect = DragDropEffects.Move
    End If
End Sub

Private Sub Form1_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
    Dim fileList As String() = DirectCast(e.Data.GetData(DataFormats.FileDrop, False), String())
    For i As Integer = 0 To fileList.Length - 1
        Dim destPath As String = "D:/pictures/"
        Directory.Move(fileList(i), destPath & Path.GetFileName(fileList(i)))
        'if only files and never directories and files you can use this instead
        'File.Move(fileList(i), destPath & Path.GetFileName(fileList(i)))
    Next
End Sub


这篇关于拖放文件到文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆