public static void BackupStorage(StorageBase s) { if (s != null) { string backupName = s.GetPath() + ".bk"; if (File.Exists(backupName)) { File.Delete(backupName); } File.Copy(s.GetPath(), backupName); } }
public static async Task <bool> RestoreStorage(StorageBase s, string url = null) { if (string.IsNullOrWhiteSpace(url)) { string backupName = s.GetPath() + ".bk"; if (!File.Exists(backupName)) { return(false); } s.Load(backupName); s.Save(); return(true); } using (WebClient wc = new WebClient()) { try { await wc.DownloadFileTaskAsync(url, s.GetPath()); } catch (Exception) { return(false); } if (!File.Exists(s.GetPath())) { return(false); } s.Load(); s.Save(); } return(true); }
private static bool Validate(StorageBase s) { if (s == null) { return(false); } if (CreateEmptyIfNeeded(s.GetPath())) { if (s.Count() > 0) { s.Save(); } return(false); } return(true); }