VB(A)

[VB.net] 폼에 드래그 하여 파일 주소 얻기

당근쨈 2016. 7. 14. 11:44

폼에 드래그하여 파일 주소를 따오는 코드

유용할 듯.



Imports System.IO


Public Class Form1


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Me.AllowDrop = True

    End Sub

    Private Sub Form1_DragDrop(sender As Object, e As DragEventArgs) Handles Me.DragDrop

        Dim theFiles() As String = CType(e.Data.GetData("FileDrop", True), String())

        For Each theFile As String In theFiles

            MsgBox(theFile)

        Next

    End Sub


    Private Sub Form1_DragEnter(sender As Object, e As DragEventArgs) Handles Me.DragEnter

        If e.Data.GetDataPresent(DataFormats.FileDrop) Then

            e.Effect = DragDropEffects.Copy

        End If

    End Sub

End Class