[FileTools] Create and use safe file/directory delete

This commit is contained in:
Matt Nadareski
2017-03-15 14:44:44 -07:00
parent 0995718106
commit 26d49d9e19
6 changed files with 88 additions and 73 deletions

View File

@@ -149,16 +149,9 @@ namespace SabreTools.Helper.Dats
// Now that we're done, delete the temp folder (if it's not the default)
Globals.Logger.User("Cleaning temp folder");
try
if (tempDir != Path.GetTempPath())
{
if (tempDir != Path.GetTempPath())
{
Directory.Delete(tempDir, true);
}
}
catch
{
// Just absorb the error for now
FileTools.SafeTryDeleteDirectory(tempDir);
}
return true;
@@ -333,18 +326,11 @@ namespace SabreTools.Helper.Dats
// Cue to delete the file if it's a copy
if (copyFiles && item != newItem)
{
try
{
Directory.Delete(newBasePath, true);
}
catch { }
FileTools.SafeTryDeleteDirectory(newBasePath);
}
// Delete the sub temp directory
if (Directory.Exists(tempSubDir))
{
Directory.Delete(tempSubDir, true);
}
FileTools.SafeTryDeleteDirectory(tempSubDir);
}
/// <summary>