Catch exceptions when deleting files/folders

This commit is contained in:
pizzaboxer 2023-08-06 14:21:27 +01:00
parent b22d72a1b8
commit b6de3645b7
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 20 additions and 2 deletions

View File

@ -920,7 +920,16 @@ namespace Bloxstrap
continue; continue;
App.Logger.WriteLine(LOG_IDENT, $"Removing old version folder for {dir.Name}"); App.Logger.WriteLine(LOG_IDENT, $"Removing old version folder for {dir.Name}");
dir.Delete(true);
try
{
dir.Delete(true);
}
catch (Exception ex)
{
App.Logger.WriteLine(LOG_IDENT, "Failed to delete version folder!");
App.Logger.WriteException(LOG_IDENT, ex);
}
} }
} }
} }

View File

@ -64,7 +64,16 @@
continue; continue;
WriteLine(LOG_IDENT, $"Cleaning up old log file '{log.Name}'"); WriteLine(LOG_IDENT, $"Cleaning up old log file '{log.Name}'");
log.Delete();
try
{
log.Delete();
}
catch (Exception ex)
{
WriteLine(LOG_IDENT, "Failed to delete log!");
WriteException(LOG_IDENT, ex);
}
} }
} }
} }