diff --git a/src/Core/Mods/JsgmeFileInstaller.cs b/src/Core/Mods/JsgmeFileInstaller.cs index 4925ebe..5974b3e 100644 --- a/src/Core/Mods/JsgmeFileInstaller.cs +++ b/src/Core/Mods/JsgmeFileInstaller.cs @@ -102,7 +102,8 @@ public static void UninstallFiles(string dstPath, IEnumerable files, Act /// Function to decide if a file should be skipped public static void UninstallFiles(string dstPath, IEnumerable files, Action fileUninstalledCallback, ShouldSkipFile skip) { - foreach (var file in files) + var fileList = files.ToList(); // It must be enumerated twice + foreach (var file in fileList) { var path = Path.Combine(dstPath, file); // Some mods have duplicate entries, so files might have been removed already @@ -120,7 +121,7 @@ public static void UninstallFiles(string dstPath, IEnumerable files, Act RestoreFile(path); fileUninstalledCallback(file); } - DeleteEmptyDirectories(dstPath, files); + DeleteEmptyDirectories(dstPath, fileList); } private static void DeleteEmptyDirectories(string dstRootPath, IEnumerable filePaths) {