Hello there, I have created and application where the items in a ListView will be dragged and dropped over the desktop. So far, I was able to implement the drag but cannot drop the item. The function I used should be detected by windows but it cannot register the drop on the desktop. Here is my code:

private void listview_ItemDrag(object sender, ItemDragEventArgs e){
  DataObject object = new DataObject()
  string f = listview.SelectedItems[0].Text;
  object.SetData(DataFormats.FileDrop, f);
  DoDragDrop(object, DragDropEffects.All);

I can't find any article that could enlighten me. I've been stuck in this code for days now. What seems to be the problem?

8 Years
Discussion Span
Last Post by LizR

Im guessing because your object doesnt contain a file, it contains a filename, and you cant just put a string object to desktop.

I googled found plenty of examples, which work - i would suggest you do the same.


You've been lucky with google my friend. I found 2 examples that adheres to my issue; one was dragging and dropping a url from a form to the desktop and the other was he gave the example that I'm using. Can you share to me the samples that you've found?


Well the first I found was a URL dropper, and he does a heck of a lot more than you've shown code for, including creating the file so it can be written to desktop.
While the file he writes is a shortcut, the principal is the same.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.