public void export(string path) { using (Stream s = File.Open(path, FileMode.Create)) { using (MetadataWriter writer = XmlMetadataWriter.Create(s)) { serializer.Export(Texture, writer, Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); } } }
private void SaveExportTexture(TextureFormatMode mode) { if (texture == null) { return; } SaveFileDialog dialog = new SaveFileDialog(); dialog.FileName = Path.GetFileNameWithoutExtension(filename); if (mode == TextureFormatMode.Unspecified) { throw new ArgumentException("Should not happen"); } dialog.Filter = serializer.Name + (mode == TextureFormatMode.Format ? "|" : " metadata + editable data|") + (mode == TextureFormatMode.Format ? serializer.PreferredFormatExtension : ".xml"); var result = dialog.ShowDialog(); if (result != DialogResult.OK) { return; } try { using (Stream s = File.Open(dialog.FileName, FileMode.Create)) { if (mode == TextureFormatMode.Format) { serializer.Save(texture, s); } else { using (MetadataWriter writer = XmlMetadataWriter.Create(s)) { serializer.Export(texture, writer, Path.GetDirectoryName(dialog.FileName), Path.GetFileNameWithoutExtension(dialog.FileName)); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }