예제 #1
0
 public static void DeleteDirectory(string path, bool recursive)
 {
     if (recursive)
     {
         var succeeded = DirectoryUtilities.DeleteDirectoryRobust(path);
         if (!succeeded)
         {
             throw new IOException("Could not delete directory " + path);
         }
     }
     else
     {
         RetryUtility.Retry(() => Directory.Delete(path, false));
     }
 }
예제 #2
0
 // See comment on class above regarding Dispose
 public void Dispose()
 {
     if (_detached)
     {
         return;
     }
     try
     {
         File.Delete(Path);
     }
     catch (IOException e)
     {
         // We tried, but we don't want to crash just because virus scanner or similar won't release the file.
         Logger.WriteMinorEvent("Could not delete temp file during Dispose(): " + e.Message);
         Debug.Fail("Could not delete temp file during Dispose(): " + e.Message, e.ToString());
     }
     if (_folderToDelete != null)
     {
         DirectoryUtilities.DeleteDirectoryRobust(_folderToDelete);
     }
 }