2012-02-23 35 views
1

在FileZilla中,我可以在远程站点上选择一个文件并将其拖到我的桌面上。 我将文件放在桌面上,FileZilla开始流式传输文件。如何将远程项目从WPF拖到桌面上?

我想实现类似的功能使用WPF - 这是可能的,它是如何做到的?

下面的代码展示了如何使用文件路径将本地文件拖动到桌面上。我的场景不同之处在于,在调用DragDrop.DoDragDrop时,文件不具有物理可用性。

//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. 

理想情况下,我希望检测'drop'事件以及有关放置位置的信息。另一种选择可能是将StreamWriter传递给DoDragDrop(),并在接收到字节时将其写入它。

+0

你想实现类似的东西:http://stackoverflow.com/questions/3040415/drag-and-drop-to-desktop-explorer? – Guillaume 2012-02-23 09:08:17

+1

@Guillaume--回答关于如何拖放已存在的文件的问题,但除非我错了,否则我不认为它涵盖了在文件被删除后流式处理文件这一更棘手的问题。 – 2012-02-23 10:22:56

+0

@ bobsmith833确实,你是对的...... – Guillaume 2012-02-23 11:07:22

回答