summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Mods.SaveBackup/ModEntry.cs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
index 30dbfbe6..33adf76d 100644
--- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs
+++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs
@@ -124,20 +124,23 @@ namespace StardewModdingAPI.Mods.SaveBackup
try
{
var oldBackups = backupFolder
- .GetFiles()
+ .GetFileSystemInfos()
.OrderByDescending(p => p.CreationTimeUtc)
.Skip(backupsToKeep);
- foreach (FileInfo file in oldBackups)
+ foreach (FileSystemInfo entry in oldBackups)
{
try
{
- this.Monitor.Log($"Deleting {file.Name}...", LogLevel.Trace);
- file.Delete();
+ this.Monitor.Log($"Deleting {entry.Name}...", LogLevel.Trace);
+ if (entry is DirectoryInfo folder)
+ folder.Delete(recursive: true);
+ else
+ entry.Delete();
}
catch (Exception ex)
{
- this.Monitor.Log($"Error deleting old save backup '{file.Name}': {ex}", LogLevel.Error);
+ this.Monitor.Log($"Error deleting old save backup '{entry.Name}': {ex}", LogLevel.Error);
}
}
}