1

In FileZilla, I can select a file on a remote site and drag it onto my desktop. After I 'drop' the file on my desktop, FileZilla starts streaming the file.

I want to achieve similar functionality using WPF - is this possible and how can it be done?

Below is a snippet which shows how to drag a local file to the desktop using it's file path. My scenario is different in that the file is not physically available when DragDrop.DoDragDrop is called.

//FileDetails holds information about where the file is downloaded from.
FileDetails fileDetails = (FileDetails)listView.ItemContainerGenerator.
    ItemFromContainer(listViewItem);

DataObject dragData = new DataObject(DataFormats.FileDrop, fileDetails);
DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Copy);
//At this point control goes to the OS.

Ideally I'd like to detect the 'drop' event with information about where the drop occured. Another option might be to pass a StreamWriter in to DoDragDrop() and write the bytes into it as they are received.

Greg Sansom
  • 20,442
  • 6
  • 58
  • 76
  • Are you trying to achieve something like that: http://stackoverflow.com/questions/3040415/drag-and-drop-to-desktop-explorer? – Guillaume Feb 23 '12 at 09:08
  • 2
    @Guillaume - that answers the question about how to do drag/drop a file that already exists, but unless I'm wrong, I don't think it covers the more tricky issue of streaming the file after the file is dropped. – Stephen Holt Feb 23 '12 at 10:22
  • @bobsmith833 Indeed, you're right... – Guillaume Feb 23 '12 at 11:07

1 Answers1

2

Have a look at this:

Creating something from nothing [Developer-friendly virtual file implementation for .NET!] - The blog of dlaa.me

I think that does what you require.

holmis83
  • 15,922
  • 5
  • 82
  • 83
Stephen Holt
  • 2,360
  • 4
  • 26
  • 34
  • It crashes running the sample code from Visual Studio, but works well when executing the .exe directly. Thanks. – Greg Sansom Feb 24 '12 at 03:42