I'm trying to achieve functionality similar to winzip/winrar, etc. I have a Treeview
that displays the contents of a package (System.IO.Packaging). I want to be able to drag and drop a file or folder from the TreeView
onto an explorer window or the desktop, etc. My problem is that I have to call DoDragDrop
before I know if the object was actually even dropped. That means to create the DataObject
with the FileDrop
type, I must extract those contents of the package out to a temporary area and then provide that path to the DataObject before calling DoDragDrop
. If the user doesn't drop on a capable container or cancels the drop, the overhead of extracting those contents is wasted. I've noticed that winzip does not actually create the temporary file until the drop occurs on a valid target. I've checked the DataFormats provided by the WinZip drop and they are normal FileDrop, FileNameW, FileName and Shell IDList Array. The first three simply hold a string to the temporary location that winzip extracted that file to. I'm not sure what the last one does.
Long story short, I want to be able to avoid extracting the contents until I know the drop location was valid. Is there a callback to figure out the drop location? Any suggestions would be extremely helpful.
System.Windows.DragDropEffects de = DragDrop.DoDragDrop(treeview1, dataObj, System.Windows.DragDropEffects.Move);