private void btnSave_Click(object sender, System.Windows.RoutedEventArgs e) { try { Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "csv files(*.csv)|*.csv"; dlg.FileName = System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv"; //dlg.InitialDirectory = "D:\\"; dlg.AddExtension = false; dlg.RestoreDirectory = true; System.Nullable <bool> result = dlg.ShowDialog(); if (result == true) { string desFilePath = dlg.FileName.ToString(); if (File.Exists(desFilePath)) { File.Delete(desFilePath); } CSVFileHelper.SaveRecordDataCSV(m_ListRecordsInfo, desFilePath); MessageBox.Show("备份数据保存成功!"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }