public void DeleteBackup() { FileIOHelper.DeleteSingleFile(SelectedBackup.FullName); BackupList.Remove(SelectedBackup); SelectedBackup = null; NotifyOfPropertyChange(() => BackupList); NotifyOfPropertyChange(() => SelectedBackup); }
public void DeleteActiveDatabase() { // Make a safety backup for the active database string source = Settings.DatabasePath; string guid = Guid.NewGuid().ToString(); string target = $"{Settings.BackupPath}Delete backup {guid}.db"; if (CopyDatabase(source, target)) { FileInfo targetFile = new FileInfo(target); BackupList.Add(targetFile); FileIOHelper.DeleteSingleFile(source); NotifyOfPropertyChange(() => CanDeleteActiveDatabase); NotifyOfPropertyChange(() => CanCreateDatabase); } }
public void RestoreBackup() { // Make a safetybackup for the active database string source = Settings.DatabasePath; string guid = Guid.NewGuid().ToString(); string target = $"{Settings.BackupPath}Restore backup {guid}.db"; if (File.Exists(source)) { if (CopyDatabase(source, target)) { FileInfo targetFile = new FileInfo(target); BackupList.Add(targetFile); FileIOHelper.DeleteSingleFile(source); CopyDatabase(SelectedBackup.FullName, source); } } else { // no active database for any reason .. CopyDatabase(SelectedBackup.FullName, source); NotifyOfPropertyChange(() => CanDeleteActiveDatabase); } }