</pre><p><img src="https://img-blog.csdn.net/20160302160055884?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" /></p><p><pre name="code" class="csharp">private void button4_Click(object sender, EventArgs e)//将文件路径显示在textBox3里
{
FolderBrowserDialog fd = new FolderBrowserDialog();
if (fd.ShowDialog() == DialogResult.OK)
textBox3.Text = fd.SelectedPath;
//---------------//
string filepath = @textBox3.Text;
//显示指定路径下的文件夹
DirectoryInfo dir = new DirectoryInfo(filepath);
foreach (DirectoryInfo d in dir.GetDirectories())
{
listBox1.Items.Add(d.Name);
}
//显示指定路径下的文件
FileInfo[] file = dir.GetFiles("*.Prj*");
foreach (FileInfo f in file)
{
listBox1.Items.Add(f.Name);
}
//-------------//
}
C#浏览按钮实现
最新推荐文章于 2024-09-27 16:45:26 发布