public static void FinalCleanUp() { //TODO: this doesn't do anything if it can't delete temp files //but we probably should handle that somehow if (WorkingDir != null) { PreviousDirs.Add(WorkingDir); } foreach (DirectoryInfo dir in PreviousDirs) { while (Directory.Exists(dir.FullName)) { //bloody WPF doesn't dispose image handles properly, //and setting the onload property stops binding //updating... so this is the answer, yikes try { dir.Delete(true); } catch (Exception) { Thread.Sleep(500); } } } }
public static void SetNewWorkingDir() { if (WorkingDir != null) { PreviousDirs.Add(WorkingDir); } string tempPath = Path.GetTempPath(); tempPath += "\\" + Guid.NewGuid().ToString(); WorkingDir = new DirectoryInfo(tempPath); WorkingDir.Create(); }