From 74d8790ee29f933c2eeb84db294030d524981b7f Mon Sep 17 00:00:00 2001 From: Pat Hartl Date: Thu, 30 Nov 2023 18:30:15 -0600 Subject: [PATCH] Fix files skipped over if not in install directory --- LANCommander.SDK/GameSaveManager.cs | 39 ++++++++++++----------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/LANCommander.SDK/GameSaveManager.cs b/LANCommander.SDK/GameSaveManager.cs index 3b2957f..5eb67d4 100644 --- a/LANCommander.SDK/GameSaveManager.cs +++ b/LANCommander.SDK/GameSaveManager.cs @@ -83,35 +83,28 @@ namespace LANCommander.SDK { var files = Directory.GetFiles(tempSavePath, "*", SearchOption.AllDirectories); - if (inInstallDir) + foreach (var file in files) { - foreach (var file in files) + if (inInstallDir) { - if (inInstallDir) - { - // Files are in the game's install directory. Move them there from the save path. - destination = file.Replace(tempSavePath, savePath.Path.Replace('/', Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar).Replace("{InstallDir}", installDirectory)); + // Files are in the game's install directory. Move them there from the save path. + destination = file.Replace(tempSavePath, savePath.Path.Replace('/', Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar).Replace("{InstallDir}", installDirectory)); - if (File.Exists(destination)) - File.Delete(destination); + if (File.Exists(destination)) + File.Delete(destination); - File.Move(file, destination); - } - else - { - // Specified path is probably an absolute path, maybe with environment variables. - destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePathFile, savePath.Path.Replace('/', '\\'))); - - if (File.Exists(destination)) - File.Delete(destination); - - File.Move(file, destination); - } + File.Move(file, destination); } - } - else - { + else + { + // Specified path is probably an absolute path, maybe with environment variables. + destination = Environment.ExpandEnvironmentVariables(file.Replace(tempSavePathFile, savePath.Path.Replace('/', '\\'))); + if (File.Exists(destination)) + File.Delete(destination); + + File.Move(file, destination); + } } } }