/// <summary> /// 导入文件的方法 /// </summary> /// <param name="type"></param> /// <param name="method"></param> private void importFile(FileType type, importOrExportFile method) { //“文本文件(*.txt)|*.txt|所有文件(*.*)|*.*” this.openFileDlg.Filter = getFileType(type); this.openFileDlg.FileName = ""; this.openFileDlg.ShowDialog(); if (!String.IsNullOrEmpty(this.openFileDlg.FileName)) { if (isFileExisted(this.openFileDlg.FileName)) { method(); } else { MessageBox.Show("导入文件不存在!!"); } } }
/// <summary> /// 导出文件的方法 /// </summary> /// <param name="type">文件的类型</param> /// <param name="write"></param> private void exportFile(FileType type, importOrExportFile method) { this.saveFileDlg.Filter = getFileType(type); this.saveFileDlg.FileName = ""; this.saveFileDlg.ShowDialog(); if (String.IsNullOrEmpty(this.saveFileDlg.FileName)) { return; } if (!isFileExisted(this.saveFileDlg.FileName)) { DialogResult result = MessageBox.Show("确定保存文件" + saveFileDlg.FileName + "?", "保存确认框", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) { method(); } } else { MessageBox.Show("同名文件已经存在!"); } }
/// <summary> /// 导出文件的方法 /// </summary> /// <param name="type">文件的类型</param> /// <param name="write"></param> private void exportFile(FileType type, importOrExportFile method) { this.saveFileDlg.Filter = getFileType(type); this.saveFileDlg.FileName = ""; this.saveFileDlg.ShowDialog(); if (String.IsNullOrEmpty(this.saveFileDlg.FileName)) return; if (!isFileExisted(this.saveFileDlg.FileName)) { DialogResult result = MessageBox.Show("确定保存文件" + saveFileDlg.FileName + "?", "保存确认框", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.Yes) method(); } else MessageBox.Show("同名文件已经存在!"); }