From c44ca404f063277193f03a580e29f48229517b0d Mon Sep 17 00:00:00 2001 From: Miepee Date: Sat, 17 Sep 2022 20:27:06 +0200 Subject: [PATCH] Try catch in case moving/deleting fails during recursive rollover --- AM2RLauncher/AM2RLauncherLib/HelperMethods.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs b/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs index d49091d..f80120e 100644 --- a/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs +++ b/AM2RLauncher/AM2RLauncherLib/HelperMethods.cs @@ -133,11 +133,19 @@ public static class HelperMethods RecursiveRollover(fileName, max); //TODO: this can fail if one doesn't have permissions to move or delete the file - // If index is less than max, rename file. - if (index < max) - File.Move(logFile, fileName); - else // Otherwise, delete the file. - File.Delete(logFile); + // maybe fixed? + try + { + // If index is less than max, rename file. + if (index < max) + File.Move(logFile, fileName); + else // Otherwise, delete the file. + File.Delete(logFile); + } + catch + { + //ignore + } } ///