Partial Class Form1
Public FL As New List(Of String)
Public Sub ContAdd(ByVal FName As String)
If FL.Contains(FName) = False Then FL.Add(FName)
End Sub
Public Function ExteJudge(ByVal FN As String) As Boolean
If System.IO.Path.HasExtension(FN) = False Then Return True
Dim Extes() As String = {".ai", ".eps"}
Dim Exte As String = String.Empty
For Each Exte In Extes
If Exte = System.IO.Path.GetExtension(FN) Then Return True
Next
Return False
End Function
Public Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Public Sub Form1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
Label1.Text = String.Empty
Dim FileNames As String() = CType(e.Data.GetData(DataFormats.FileDrop, False), String())
Me.Refresh()
FL.Clear()
Dim files As String()
For Each FName As String In FileNames
If GetAttr(FName) = FileAttribute.Directory Then
files = System.IO.Directory.GetFiles(FName)
For Each FileName As String In files
If ExteJudge(FileName) = True Then ContAdd(FileName)
Next
Else
If ExteJudge(FName) = True Then ContAdd(FName)
End If
Next
If FL.Count = 0 Then
Console.WriteLine("適切なファイルが選択されていません") : Exit Sub
ElseIf FL.Count > 0 Then
FL.Sort()
Me.ListBox1.Items.Clear()
For Each aaa As String In FL
Me.ListBox1.Items.Add(Dir(aaa))
Next
End If
End Sub
End Class