c# 读取文件目录下的信息
程序员文章站
2022-05-27 09:26:34
private void button1_Click(object sender, System.EventArgs e) { //浏览文件夹 this.folderBrowserDialog1.ShowDialog(); if(this.folderBrowserDialog1.SelectedP ......
private void button1_click(object sender, system.eventargs e)
{
//浏览文件夹
this.folderbrowserdialog1.showdialog();
if(this.folderbrowserdialog1.selectedpath.trim()!="")
this.textbox1.text=this.folderbrowserdialog1.selectedpath.trim();
}
private void button2_click(object sender, system.eventargs e)
{
//显示指定文件夹下的文件
if(this.textbox1.text.trim()=="")
return;
this.listbox1.items.clear();
string[] myfiles=system.io.directory.getfiles(this.textbox1.text);
this.listbox1.items.addrange(myfiles);
//foreach(string file in myfiles)
// this.listbox1.items.add(file);
}