public bool ExportToFile(string filePath) { this.shapePersistance.SetShapeTheme(Path.GetFileNameWithoutExtension(filePath)); var dataPath = ShapePersistence.GetPersistenceDir(); try { ZipFile.CreateFromDirectory(dataPath, filePath, CompressionLevel.Fastest, false); } catch(Exception e) { logger.Log("Exception while exporting: " + e.Message); return false; } logger.Log("Export successful."); return true; }
public bool ImportFromFile(string filePath) { try { var persistenceDir = ShapePersistence.GetPersistenceDir(); Directory.Delete(persistenceDir, true); Directory.CreateDirectory(persistenceDir); ZipFile.ExtractToDirectory(filePath, persistenceDir); this.shapePersistance.InstallPersistedTheme(); this.shapePersistance.LoadShapes(); } catch(Exception e) { logger.Log("Exception while importing from file: " + e.Message); return false; } logger.Log("Import successful."); return true; }