Esempio n. 1
0
 public static bool FireFileReplacing(string fileName, bool isDirectory)
 {
     FileCancelEventArgs e = new FileCancelEventArgs(fileName, isDirectory);
     if (FileReplacing != null)
     {
         FileReplacing(null, e);
     }
     return !e.Cancel;
 }
Esempio n. 2
0
 private static void OnFileRemoving(FileCancelEventArgs e)
 {
     if (FileRemoving != null)
     {
         FileRemoving(null, e);
     }
 }
Esempio n. 3
0
 public static void RemoveFile(string fileName, bool isDirectory)
 {
     FileCancelEventArgs e = new FileCancelEventArgs(fileName, isDirectory);
     OnFileRemoving(e);
     if (!e.Cancel)
     {
         if (!e.OperationAlreadyDone)
         {
             Exception exception;
             if (isDirectory)
             {
                 try
                 {
                     if (Directory.Exists(fileName))
                     {
                         Directory.Delete(fileName, true);
                     }
                 }
                 catch (Exception exception1)
                 {
                     exception = exception1;
                     MessageService.ShowError(exception, "Can't remove directory " + fileName);
                 }
             }
             else
             {
                 try
                 {
                     if (File.Exists(fileName))
                     {
                         File.Delete(fileName);
                     }
                 }
                 catch (Exception exception2)
                 {
                     exception = exception2;
                     MessageService.ShowError(exception, "Can't remove file " + fileName);
                 }
             }
         }
         OnFileRemoved(new FileEventArgs(fileName, isDirectory));
     }
 }