private void button1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false;//该值确定是否可以选择多个文件 dialog.Title = "请选择文件夹"; dialog.Filter = "文本文件(*.txt*)|*.txt*"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string file = dialog.FileName; //this.txtPath.Text = file; Console.WriteLine(file); } else { MessageBox.Show("未选中配置文件"); } }