vb.net怎么把一个文件夹的所有文件都添加到listbox里。 100
1个回答
展开全部
定义一个窗体继承自System.Windows.Forms.Form。
添加以下控件对象到窗体:
Private folderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
Private button1 As System.Windows.Forms.Button
Private listBox1 As System.Windows.Forms.ListBox
给button1的Click事件添加以下处理程序:
Sub Button1Click(sender As Object, e As EventArgs)
If System.Windows.Forms.DialogResult.OK=Me.folderBrowserDialog1.ShowDialog(Me) Then
Me.listBox1.Items.AddRange(System.IO.Directory.GetFiles(Me.folderBrowserDialog1.SelectedPath))
End If
End Sub
添加以下控件对象到窗体:
Private folderBrowserDialog1 As System.Windows.Forms.FolderBrowserDialog
Private button1 As System.Windows.Forms.Button
Private listBox1 As System.Windows.Forms.ListBox
给button1的Click事件添加以下处理程序:
Sub Button1Click(sender As Object, e As EventArgs)
If System.Windows.Forms.DialogResult.OK=Me.folderBrowserDialog1.ShowDialog(Me) Then
Me.listBox1.Items.AddRange(System.IO.Directory.GetFiles(Me.folderBrowserDialog1.SelectedPath))
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询