vb.net怎么把一个文件夹的所有文件都添加到listbox里。

2024-11-15 20:38:16
推荐回答(1个)
回答1:

使用FolderBrowserDialog控件
If FolderBrowserDialog1.ShowDialog() <> DialogResult.Cancel Then
TextBox6.Text = FolderBrowserDialog1.SelectedPath
TextBox6.SelectionStart = TextBox6.Text.Length
Dim FileNames() As String = Directory.GetFiles(TextBox6.Text)
For i As Integer = 0 To FileNames.Length - 1
ListBox1.Items.Add(Path.GetFileName(FileNames(i)))
Next
End If