private void ExcelPath_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = "d:\\"; dialog.RestoreDirectory = true; dialog.Filter = "Excel文件 | *.xlsx"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ExcelPath_textBox.Clear(); excelPath = dialog.FileName; excelFile = new ExcelFile(excelPath); if (excelFile.CheckValidation()) { ExcelPath_textBox.Text = dialog.FileName; } } }