打开文件夹中默认路径下的excl文件
private void button7_Click(object sender, EventArgs e) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.SelectedPath = "D:";//默认打开d盘 if (fbd.ShowDialog() == DialogResult.OK) { textBox1.Text = fbd.SelectedPath; DirectoryInfo dif = new DirectoryInfo(textBox1.Text); FileInfo[] fis = dif.GetFiles();//取所有文件信息 foreach (FileInfo fi in fis) { if (fi.Name.ToLower().Contains(".xls") || fi.Name.ToLower().Contains(".xlsx")) { listView1.Items.Add(fi.Name); } } } }
原文地址:https://www.cnblogs.com/SoftWareIe/p/10202155.html
时间: 2024-10-16 04:56:58