Beispiel #1
0
 public static bool CopyItems(List <string> items, string destination)
 {
     try
     {
         var fs = new SHFILEOPSTRUCT
         {
             wFunc = FileOperationType.FO_COPY,
             pFrom = string.Join("\0", items.ToArray()) + '\0' + '\0',
             pTo   = destination + '\0' + '\0'
         };
         SHFileOperation(ref fs);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #2
0
 private static bool deleteFile(string path, FileOperationFlags flags)
 {
     try
     {
         var fs = new SHFILEOPSTRUCT
         {
             wFunc  = FileOperationType.FO_DELETE,
             pFrom  = path + '\0' + '\0',
             fFlags = flags
         };
         SHFileOperation(ref fs);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Send file to 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)
 {
     try
     {
         var fs = new SHFILEOPSTRUCT
         {
             wFunc  = FileOperationType.FO_DELETE,
             pFrom  = path + '\0' + '\0',
             fFlags = FileOperationFlags.FOF_ALLOWUNDO | flags
         };
         SHFileOperation(ref fs);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #4
0
 private static extern int SHFileOperation(ref SHFILEOPSTRUCT FileOp);
Beispiel #5
0
 /// <summary>
 /// Copies, moves or deletes a filesystem object using shell functionality
 /// (I.e. shows an OS dialog on overwrite, can move files to the recycle bin, ...)
 /// </summary>
 /// <param name="lpFileOp">Descriptor of the file operation to execute</param>
 /// <returns>An error code. please note that this function has its own set of error codes documented
 /// here: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762164(v=vs.85).aspx </returns>
 public virtual int ShellFileOperation(ref SHFILEOPSTRUCT lpFileOp)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 public static extern int SHFileOperation([In] ref SHFILEOPSTRUCT lpFileOp);