所以,基本上我将一个文件夹拖到表单上,一个列表框会填充里面文件的路径。我已经设法让列表框只接受 .MP3 路径,但是如何添加更多接受的扩展?
Private Sub Form1_DragDrop(sender As System.Object, e As System.Windows.Forms.DragEventArgs) Handles Me.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each path In files
If Directory.Exists(path) Then
'Add the contents of the folder to Listbox1
ListBox1.Items.AddRange(IO.Directory.GetFiles(path, "*.mp3*"))
正如您在上面的最后一行中所看到的,接受具有 .mp3 扩展名的文件夹中的路径。如何添加更多可接受的扩展名,如 .avi、.mp4 等?
我试过了ListBox1.Items.AddRange(IO.Directory.GetFiles(path, "*.mp3*" + "*.mp4*"))
我也试过ListBox1.Items.AddRange(IO.Directory.GetFiles(path, "*.mp3*" , "*.mp4*"))
没运气 !