/// <summary> /// 导出当前对象 /// </summary> public static void ExportObject(object obj , string defaultFileName = null , params string[] defaultFileExtentions) { string fileName = defaultFileName; string[] fileExtentions; if (defaultFileExtentions.IsNotNullOrEmpty()) { fileExtentions = defaultFileExtentions; } else { fileExtentions = new string[] { FileExtentions.CONFIG , FileExtentions.XML , FileExtentions.All }; } if (UIPublic.ShowSaveFileDialog("导出", ref fileName , fileExtentions) == DialogReturn.OK) { if (fileName.IsNullOrEmpty()) { UIPublic.ShowErrorDialog("输入了错误的文件名"); } else { IOPublic.WriteObjectToFile(fileName, obj); } } }
private void ButtonSave_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string fileName = "*.png"; if (UIPublic.ShowSaveFileDialog("保存图片", ref fileName , FileExtentions.PNG , FileExtentions.JPG , FileExtentions.BMP , FileExtentions.All) == DialogReturn.OK) { PictureEdit.Image.Save(fileName); } }
/// <summary> /// 导出 /// </summary> public void Export() { if (ExportFileFilters == null) { throw new Exception("未定义可导出的扩展名"); } string fileName = ""; if (UIPublic.ShowSaveFileDialog("导出", ref fileName, ExportFileFilters) == DialogReturn.OK) { OnExport(fileName); } }