Private Sub txtTemp_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtTemp.DragEnter
'ファイル形式の場合のみ、ドラッグを受け付けます。
If e.Data.GetDataPresent(DataFormats.FileDrop) = True Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub txtTemp_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtTemp.DragDrop
'ドラッグされたファイル・フォルダのパスを格納します。
Dim strFileName As String() = CType(e.Data.GetData(DataFormats.FileDrop, False), String())
'ファイルの存在確認を行い、ある場合にのみ、
'テキストボックスにパスを表示します。
'(この処理でフォルダを対象外にしています。)
If System.IO.File.Exists(strFileName(0).ToString) = True Then
Me.txtTemp.Text = strFileName(0).ToString
End If
End Sub
|
|