string defaultfilePath = ""; private void btn_OpenFile_Click(object sender, EventArgs e) { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowNewFolderButton = false; dialog.Description = "请选择文件路径"; if (defaultfilePath != "") { //设置此次默认目录为上一次选中目录 dialog.SelectedPath = defaultfilePath; } DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK || result == DialogResult.Yes) { string foldPath = dialog.SelectedPath; txt_Directory.Text = defaultfilePath = foldPath; string[] files = Directory.GetFiles(txt_Directory.Text + @"", "*.xls"); foreach (string file in files) { MessageBox.Show(file); } } }