private void RemoveOldBackups(FileSystemPath newBackup, IEnumerable <GameBackups_ExistingBackup> existingBackups) { try { foreach (GameBackups_ExistingBackup existingBackup in existingBackups) { // Ignore the newly created backup if (existingBackup.Path.CorrectPathCasing().Equals(newBackup.CorrectPathCasing())) { continue; } if (existingBackup.IsCompressed) { // Delete the file File.DeleteFile(existingBackup.Path); Logger.Info("Compressed leftover backup was deleted"); } else { // Delete the directory File.DeleteDirectory(existingBackup.Path); Logger.Info("Non-compressed leftover backup was deleted"); } } } catch (Exception ex) { Logger.Error(ex, "Deleting leftover backups"); } }
/// <summary> /// Creates a new link item for a local path /// </summary> /// <param name="localLinkPath">The local link path</param> /// <param name="displayText">The text to display for the link</param> /// <param name="minUserLevel">The minimum required user level for this link item</param> public Page_Settings_LinkItemViewModel(FileSystemPath localLinkPath, string displayText, UserLevel minUserLevel = UserLevel.Normal) { MinUserLevel = minUserLevel; LocalLinkPath = localLinkPath.Exists ? localLinkPath.CorrectPathCasing() : localLinkPath; IsLocal = true; DisplayText = displayText; IconKind = localLinkPath.FileExists ? PackIconMaterialKind.FileOutline : PackIconMaterialKind.FolderOutline; OpenLinkCommand = new AsyncRelayCommand(OpenLinkAsync); }