1 using System.Collections.Generic;
2 using System.ComponentModel;
3 using System.Data;
4 using System.Drawing;
5 using System.Text;
6 using System.Windows.Forms;
7 namespace WindowsApplication1 {
8 publicpartialclass SelectFolder: Form {
9 public SelectFolder()
10 {
11 InitializeComponent();
12 }
13 privatevoid btnSelectPath_Click(object sender, EventArgs e) //弹出一个选择目录的对话框
14 {
15 FolderBrowserDialog path = new FolderBrowserDialog();
16 path.ShowDialog();
17 this.txtPath.Text = path.SelectedPath;
18 }
19 privatevoid btnSelectFile_Click(object sender, EventArgs e) //弹出一个选择文件的对话框
20 {
21 OpenFileDialog file = new OpenFileDialog();
22 file.ShowDialog();
23 this.txtFile.Text = file.SafeFileName;
24 }
25 }
26 }winforms 的openFileDialog1能实现 选择文件夹里面的多个<文件名>一次导入到LISTBOX下呢 !this.openFileDialog1.Multiselect = true;this.openFileDialog1.ShowDialog();foreach(string fName in this.openFileDialog1.FileNames){ this.listBox1.Items.Add(fName);}读取选择好的,文件全地址及名称
27 OpenFileDialog openfiledialot = new OpenFileDialog();
28 openfiledialot.ShowDialog();
29 this.textBox1.Text = openfiledialot.FileName.ToString();