可以直接看代码
public bool showDialogGetExcel(out string excelName)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = @"Excel文件|*.xls;*.xlsx";
openFileDialog.RestoreDirectory = true;
openFileDialog.FilterIndex = 1;
bool dialogResult = openFileDialog.ShowDialog() == DialogResult.OK;
excelName = openFileDialog.FileName;
return dialogResult;
}
public bool showDialogGetSaveFolder(out string folderPath)
{
FolderBrowserDialog dlg = new FolderBrowserDialog();
bool dialogResult = dlg.ShowDialog() == DialogResult.OK;
folderPath = dlg.SelectedPath.ToString();
return dialogResult;
}