From 11cc52a9d7fcce6c78daa8b76a12bb9e1a9ed35b Mon Sep 17 00:00:00 2001 From: alcexhim Date: Wed, 14 Oct 2015 14:08:00 -0400 Subject: [PATCH] Skip over files in use to prevent crash but maintain a list so we can delete them next time if possible (not implemented) --- .../TemporaryFileManager.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/TemporaryFileManager.cs b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/TemporaryFileManager.cs index 004c1d50..f7699370 100644 --- a/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/TemporaryFileManager.cs +++ b/CSharp/Engines/WindowsForms/Libraries/UniversalEditor.UserInterface.WindowsForms/TemporaryFileManager.cs @@ -46,14 +46,23 @@ internal static class TemporaryFileManager { if (mvarTemporaryFilePath == null) return false; + System.Collections.Generic.List fileNamesNotDeleted = new System.Collections.Generic.List(); + foreach (string fileName in mvarTemporaryFileNames) { if (System.IO.File.Exists(fileName)) { - System.IO.File.Delete(fileName); + try + { + System.IO.File.Delete(fileName); + } + catch (Exception ex) + { + fileNamesNotDeleted.Add(fileName); + } } } - if (System.IO.Directory.Exists(mvarTemporaryFilePath)) + if (System.IO.Directory.Exists(mvarTemporaryFilePath) && fileNamesNotDeleted.Count == 0) { System.IO.Directory.Delete(mvarTemporaryFilePath, true); }