Ejemplo n.º 1
0
 //--------------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Send the specified file or directory to the recycle bin.
 /// </summary>
 /// <param name="path">Location of directory or file to recycle</param>
 /// <param name="flags">FileOperationFlags to add in addition to FOF_ALLOWUNDO</param>
 //--------------------------------------------------------------------------------------------------------------
 public static bool Send(string path, FileOperationFlags flags = FileOperationFlags.FOF_NOCONFIRMATION | FileOperationFlags.FOF_WANTNUKEWARNING)
 {
     try
     {
         if (IsWOW64Process())
         {
             var fs = new ShFileOpStructX64
             {
                 wFunc  = FileOperationType.FO_DELETE,
                 pFrom  = path + '\0' + '\0',                                // important to double-terminate the string.
                 fFlags = FileOperationFlags.FOF_ALLOWUNDO | flags
             };
             SHFileOperationx64(ref fs);
         }
         else
         {
             var fs = new ShFileOpStructX86
             {
                 wFunc  = FileOperationType.FO_DELETE,
                 pFrom  = path + '\0' + '\0',                                // important to double-terminate the string.
                 fFlags = FileOperationFlags.FOF_ALLOWUNDO | flags
             };
             SHFileOperationx86(ref fs);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 2
0
 private static extern int SHFileOperationx64(ref ShFileOpStructX64 fileOp);