示例#1
0
    private void Do_Copy_OR_Move_Helper(Boolean copy, IListItemEx destination, IShellItem[] items) {
      var handle = this.Handle;
      var thread = new Thread(() => {
        var fo = new IIFileOperation(handle);
        foreach (var item in items) {
          if (copy)
            fo.CopyItem(item, destination);
          else
            fo.MoveItem(item, destination, null);
        }
        fo.PerformOperations();
      });

      thread.SetApartmentState(ApartmentState.STA);
      thread.Start();
    }
示例#2
0
    private void Do_Copy_OR_Move_Helper_2(Boolean copy, IListItemEx destination, F.IDataObject dataObject) {
      IntPtr handle = this.Handle;
      IShellItemArray shellItemArray = null;
      IShellItem[] items = null;

      if (((F.DataObject)dataObject).ContainsFileDropList()) {
        items = ((F.DataObject)dataObject).GetFileDropList().OfType<String>().Select(s => ShellItem.ToShellParsingName(s).ComInterface).ToArray();
      } else {
        shellItemArray = dataObject.ToShellItemArray();
        items = shellItemArray.ToArray();
      }
      var thread = new Thread(() => {
        try {
          var fo = new IIFileOperation(handle);
          foreach (var item in items) {
            if (copy)
              fo.CopyItem(item, destination);
            else
              fo.MoveItem(item, destination, null);
          }

          fo.PerformOperations();
        } catch (SecurityException) {
          throw;
        }
      });

      thread.SetApartmentState(ApartmentState.STA);
      thread.Start();
    }
示例#3
0
    public void PasteAvailableFiles() {
      var handle = this.Handle;
      var view = this;
      var thread = new Thread(() => {
        var dataObject = F.Clipboard.GetDataObject();
        var dropEffect = dataObject.ToDropEffect();
        if (dataObject != null && dataObject.GetDataPresent("Shell IDList Array")) {
          var shellItemArray = dataObject.ToShellItemArray();
          var items = shellItemArray.ToArray();

          try {
            var sink = new FOperationProgressSink(view);
            var controlItem = FileSystemListItem.InitializeWithIShellItem(this.LVHandle, items.First()).Parent;
            var fo = new IIFileOperation(sink, handle, true, controlItem.Equals(this.CurrentFolder));
            if (dropEffect == System.Windows.DragDropEffects.Copy) {
              fo.CopyItems(shellItemArray, this.CurrentFolder);
            } else {
              fo.MoveItems(shellItemArray, this.CurrentFolder);
            }

            fo.PerformOperations();
            Marshal.ReleaseComObject(shellItemArray);
          } catch (SecurityException) {
            throw;
          }
        } else if (dataObject != null && dataObject.GetDataPresent("FileDrop")) {
          var items = ((String[])dataObject.GetData("FileDrop")).Select(s => ShellItem.ToShellParsingName(s).ComInterface).ToArray();
          try {
            var sink = new FOperationProgressSink(view);
            var controlItem = FileSystemListItem.InitializeWithIShellItem(this.LVHandle, items.First()).Parent;
            var fo = new IIFileOperation(sink, handle, true, controlItem.Equals(this.CurrentFolder));
            foreach (var item in items) {
              if (dropEffect == System.Windows.DragDropEffects.Copy)
                fo.CopyItem(item, this.CurrentFolder);
              else
                fo.MoveItem(item, this.CurrentFolder, null);
            }

            fo.PerformOperations();
          } catch (SecurityException) {
            throw;
          }
        }
        this.LargeImageList.SupressThumbnailGeneration(false);
      });

      thread.SetApartmentState(ApartmentState.STA);
      thread.Start();
      Shell32.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
    }