Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs =================================================================== diff -u -r7f31ca0fcf345c32456094e6ede3e2fbb2c86ad9 -r70f7bc2ec3c640350e2525c888837254657d6315 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision 7f31ca0fcf345c32456094e6ede3e2fbb2c86ad9) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.IO/Exporters/MacroStabilityInwardsCalculationGroupExporter.cs (.../MacroStabilityInwardsCalculationGroupExporter.cs) (revision 70f7bc2ec3c640350e2525c888837254657d6315) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System.Threading; using Components.Persistence.Stability; using Core.Common.Base.Data; using Core.Common.Base.IO; @@ -137,7 +138,7 @@ { if (Directory.Exists(tempFolderPath)) { - Directory.Delete(tempFolderPath, true); + DeleteDirectory(tempFolderPath); } } } @@ -228,5 +229,22 @@ var fileNameWithExtension = $"{fileName}.{fileExtension}"; return Path.Combine(currentFolderPath, fileNameWithExtension); } + + private static void DeleteDirectory(string directory, int numberOfRetries = 5) + { + try + { + Directory.Delete(directory, true); + } + catch (IOException) + { + Thread.Sleep(1000); + + if (numberOfRetries != 0) + { + DeleteDirectory(directory, numberOfRetries - 1); + } + } + } } } \ No newline at end of file