internal bool TryExportAttachment() { if (State.File.FrontCard.Attachment != null) { AttachmentFile attachment = State.File.FrontCard.Attachment; string ext = Path.GetExtension(attachment.Name); if (ext != "") { exportAttachmentDialog.Filter = string.Format( Language.Get("ExportAttachmentFilter", "{1} (*.{0})|*.{0}|All files (*.*)|*"), ext, Win32Util.GetFileDescription(ext) ?? string.Format(Language.Get("UnknownExtension", "{0} File"), ext)); } else { exportAttachmentDialog.Filter = Language.Get("ExportAttachmentFilterNoExt", "All files (*.*)|*"); } exportAttachmentDialog.FileName = attachment.Name; DialogResult result = exportAttachmentDialog.ShowDialog(); if (result == DialogResult.OK) { string filePath = exportAttachmentDialog.FileName; try { UseWaitCursor = true; File.WriteAllBytes(filePath, attachment.Data); } catch (IOException) { MessageBox.Show( this, Language.Get("CannotExportAttachment", "An error occurred while exporting the attachment. Make sure the file is not read-only and that you have sufficient disk space."), this.ProgramName, MessageBoxButtons.OK, MessageBoxIcon.Hand); } finally { UseWaitCursor = false; } return(true); } return(false); } return(false); }