【问题标题】:How to drag remote item from WPF onto desktop?如何将远程项目从 WPF 拖到桌面上?
【发布时间】:2012-02-23 08:59:00
【问题描述】:

在 FileZilla 中,我可以选择远程站点上的文件并将其拖到我的桌面上。 之后我将文件“拖放”到桌面上,FileZilla 开始流式传输文件。

我想使用 WPF 实现类似的功能 - 这可能吗?如何实现?

下面是一个 sn-p,它显示了如何使用文件路径将本地文件拖到桌面。我的情况有所不同,因为调用 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() 并在收到字节时将其写入其中。

【问题讨论】:

  • 您是否正在尝试实现类似的目标:stackoverflow.com/questions/3040415/…?
  • @Guillaume - 回答了有关如何拖放已经存在的文件的问题,但除非我错了,否则我认为它不会涵盖流式传输文件的更棘手的问题文件被删除后。
  • @bobsmith833 的确,你是对的......

标签: c# .net wpf drag-and-drop


【解决方案1】:

【讨论】:

  • 从 Visual Studio 运行示例代码会崩溃,但在直接执行 .exe 时运行良好。谢谢。
猜你喜欢
  • 2020-10-29
  • 2010-11-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多