Michael Foster
Michael Foster

Reputation: 125

How to get a windows shell Drop Handler to work for folders

I am trying to write a windows shell extension. My goal is to have a handler that can handle all drag and drop operations on a folder. When files are dropped on a folder, I want to execute my business logic which will either

  1. Take control of the drag and drop operation OR
  2. Let windows do its default behavior.

I am using SharpShell as an easy way to implement the shell extension. It works, but not as i expected. It seems like the shell extension lets you handle the case of "what if a file is dropped on a FILE". Like, if i drop a PDF on a text file, I can intercept that. But DragEnter or Drop is never called when dragging (and dropping) files on a folder.

Is what I want to do supported without a namespace extension?

[ComVisible(true)]
[COMServerAssociation(AssociationType.AllFilesAndFolders)]
public class MyDropHandler : SharpDropHandler
{
    protected override void DragEnter(DragEventArgs dragEventArgs)
    {
        dragEventArgs.Effect = DragDropEffects.Copy;
    }

    protected override void Drop(DragEventArgs dragEventArgs)
    {
        System.Diagnostics.Debugger.Launch();
    }
}

Upvotes: 0

Views: 76

Answers (0)

Related Questions