drag-n-drop 是很多网站(这也是)中讨论得很好的话题,我也发现了很好的问题,但没有答案.
drag-n-drop is a pretty discussed topic in a lot sites (this too) and i found nice questions too, but no answer to this case.
我有一个包含一些元素的 listView,我需要将它们放在 Windows Explorer 上.删除时,我只需要删除文件的路径,我不需要复制任何内容,只需要路径.
I have a listView with some elements and i need them to be droppable on the Windows Explorer. When dropped i need only the file path where those are dropped, i don't need to copy anything, just need the path.
类似的问题(以及为什么它们不适合我):
Similar question (and why they don't work for me):
我找到的唯一解决方案:
The only solution i found:
http://www.codeproject.com/Articles/23207/Drag-and-Drop-to-Windows-Folder-C
这可行,但以一种非常不切实际"的方式,它创建一个文件观察器,创建一个虚拟文件,让 DragDrop 函数复制它,观察它的创建位置,最后删除它.在我的 Windows8.1 中测试它会导致资源管理器刷新不正确,在我刷新屏幕 (F5) 之前我仍然可以看到该文件.
This works but in a very "unpratical" way, it creates a file watcher, create a dummy file, let the DragDrop function copy it, watch where it was created and finally delete it. Testing it in my Windows8.1 results in a incorrect Explorer refresh and i can still see the file until i refresh my screen (F5).
这是唯一的方法吗?我仍然无法相信我无法以更简单的方式实现这一目标
Is this the only way? I still can't believe i can't achieve this in a simpler way
想一想...如果你知道拖放,那么你就会知道拖动源担心将数据打包成正确的格式和拖动目标担心以正确的格式检索数据.您的问题是您的拖动目标不在您的 WPF 应用程序中,因此在删除数据时您可以做的事情很少.
Think about it for a minute... if you know about drag and drop, then you'll know that the drag source worries about packaging up the data into the correct format and the drag target worries about retrieving the data in the correct format. Your problem is that your drag target is not in your WPF application and so there is very little that you can do as the data is dropped.
更好的解决方案是实现自己的基本文件浏览器,然后作为应用程序的一部分,通过拖放操作访问文件路径会简单得多.无论哪种方式,你都有很多工作要做.
A much better solution would be to implement your own basic file browser and then as part of your application, it would be far simpler to access the file path with the drag and drop operation. Either way, you've got a lot of work to do.
这篇关于在 Windows 资源管理器上获取拖放文件的文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!