private void ExportBytes(CVariable editvar) { var dlg = new SaveFileDialog(); byte[] bytes = null; if (editvar is IByteSource) { bytes = ((IByteSource)editvar).Bytes; } dlg.Filter = string.Join("|", ImportExportUtility.GetPossibleExtensions(bytes)); dlg.InitialDirectory = Get().Configuration.InitialExportDirectory; if (dlg.ShowDialog() == DialogResult.OK) { Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName); using (var fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write)) { using (var writer = new BinaryWriter(fs)) { bytes = ImportExportUtility.GetExportBytes(bytes, Path.GetExtension(dlg.FileName)); writer.Write(bytes); } } } }
public void ExportBytes(IByteSource editvar) { var dlg = new SaveFileDialog(); var bytes = editvar.GetBytes(); dlg.Filter = string.Join("|", ImportExportUtility.GetPossibleExtensions(bytes, (CVariable)editvar)); dlg.InitialDirectory = MainController.Get().Configuration.InitialExportDirectory; if (dlg.ShowDialog() == DialogResult.OK) { MainController.Get().Configuration.InitialExportDirectory = Path.GetDirectoryName(dlg.FileName); using (var fs = new FileStream(dlg.FileName, FileMode.Create, FileAccess.Write)) using (var writer = new BinaryWriter(fs)) { bytes = ImportExportUtility.GetExportBytes(bytes, Path.GetExtension(dlg.FileName), (CVariable)editvar); writer.Write(bytes); MainController.LogString( $"{((CVariable) editvar).GetFullDependencyStringName()} succesfully exported to {dlg.FileName}", Logtype.Success); } } }