예제 #1
0
 /// <summary>
 /// Deletes files/directories by sending them to recycle bin
 /// </summary>
 public static Boolean Recycle(String path)
 {
     if (Win32.ShouldUseWin32())
     {
         InteropSHFileOperation fo = new InteropSHFileOperation();
         fo.wFunc = InteropSHFileOperation.FO_Func.FO_DELETE;
         fo.fFlags.FOF_ALLOWUNDO      = true;
         fo.fFlags.FOF_NOCONFIRMATION = true;
         fo.fFlags.FOF_NOERRORUI      = true;
         fo.fFlags.FOF_SILENT         = true;
         fo.pFrom = path;
         return(fo.Execute());
     }
     else // Delete directly on other platforms
     {
         if (File.Exists(path))
         {
             File.Delete(path);
             return(true);
         }
         else if (Directory.Exists(path))
         {
             Directory.Delete(path);
             return(true);
         }
         return(false);
     }
 }
예제 #2
0
        /// <summary>
        /// Deletes files/directories by sending them to recycle bin
        /// </summary>
        public static Boolean Recycle(String path)
        {
            InteropSHFileOperation fo = new InteropSHFileOperation();

            fo.wFunc = InteropSHFileOperation.FO_Func.FO_DELETE;
            fo.fFlags.FOF_ALLOWUNDO      = true;
            fo.fFlags.FOF_NOCONFIRMATION = true;
            fo.fFlags.FOF_NOERRORUI      = true;
            fo.fFlags.FOF_SILENT         = true;
            fo.pFrom = path;
            return(fo.Execute());
        }