예제 #1
0
 public static bool DeleteWithRecycleBin(string path, bool forceDelete = false)
 {
     if (Application.platform == RuntimePlatform.WindowsEditor ||
         Application.platform == RuntimePlatform.WindowsPlayer)
     {
         var operation = new ShellFileOpStruct {
             FunctionCode = 0x3,    // FO_DELETE
             From         = path + "\0\0",
             Flags        = 0x004 | // FOF_SILENT
                            0x010 | // FOF_NOCONFIRMATION
                            0x040 | // FOF_ALLOWUNDO
                            0x400,  // FOF_NOERRORUI
         };
         bool deleted = SHFileOperation(ref operation) == 0;
         if (!deleted && forceDelete)
         {
             File.Delete(path);
             return(true);
         }
         return(deleted);
     }
     else
     {
         File.Delete(path);
         return(true);
     }
 }
예제 #2
0
 private static extern int SHFileOperation(ref ShellFileOpStruct operation);