简体   繁体   English

将文件拖放到 wpf/C# 应用程序时,如何在 Windows 资源管理器中维护文件顺序?

[英]How do I maintain the file order in Windows Explorer when drag and dropping files into wpf/C# application?

In my application the user can drag and drop files from windows explorer onto a listbox in my application.在我的应用程序中,用户可以将文件从 windows 资源管理器拖放到我的应用程序的列表框中。 This all works excellent however when dragging multiple files, depending which file the user clicks in windows explorer to begin dragging, the order the files passed will differ when calling:这一切都很好,但是在拖动多个文件时,这取决于用户在 windows 资源管理器中单击哪个文件开始拖动,调用时传递的文件顺序会有所不同:

e.Data.GetData(DataFormats.FileDrop)

How do I receive the files in the same order as they are displayed in windows explorer?如何以与 windows 资源管理器中显示的顺序相同的顺序接收文件?

Thanks for your help!谢谢你的帮助!

The order you receive them is the order in which they were selected.您收到它们的顺序是它们被选中的顺序。 I encountered this problem once before and as far as I was able to tell you cannot get them in Explorer's sort order.我以前遇到过这个问题,据我所知,你无法按照资源管理器的排序顺序获取它们。

Therefore your code should assume the user selected them in that order for a reason.因此,您的代码应该假设用户按该顺序选择它们是有原因的。

If you shift-select a bunch of files from 0000 to 0010 and then drag them into an application (say video files and drag them into VLC).如果您从 0000 到 0010 选择一堆文件,然后将它们拖到应用程序中(比如视频文件并将它们拖到 VLC 中)。 Explorer will feed the list not in the order you selected the items but from the item you left-click-n-dragged from.资源管理器将不按照您选择项目的顺序提供列表,而是从您左键单击并拖动的项目中提供。

Click on 0000 and they will show up in number order.单击 0000,它们将按数字顺序显示。 Click on 0003 and they will show up from 0003 to 0010 and then 0001 and 0002单击 0003,它们将显示从 0003 到 0010,然后是 0001 和 0002

So the correct way to "drag n drop" is to always drag from the top.所以“拖放”的正确方法是始终从顶部拖动。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何允许从Windows资源管理器拖放到C#WPF应用程序中? - How can I allow Drag and Drop from Windows Explorer into a C# WPF application? C#如何使用Directory.GetFiles()获取与Windows资源管理器中的顺序相同的文件? - C# How do I use Directory.GetFiles() to get files that have the same order as in Windows explorer? 如何在C#中将文件夹/文件从一个Windows资源管理器拖放到另一个Windows资源管理器? - How to drag and drop folders/files from One Windows Explorer to another windows explorer in C#? 将大型虚拟文件从 C# 拖放到 Windows 资源管理器 - Drag and drop large virtual files from C# to Windows Explorer WPF:将虚拟文件拖放到Windows资源管理器中 - WPF: Drag and drop virtual files into Windows explorer C#:如何处理/解析应用程序的消息,例如拖放相关的文件类型? - C#: How do you handle/parse messages for your applications like drag and dropping an associated file type? 如何创建“Shell IDList Array”以支持将虚拟文件从C#拖放到Windows资源管理器? - How to create a “Shell IDList Array” to support drag-and-drop of virtual files from C# to Windows Explorer? 将文件从(例如)Windows资源管理器中的文件拖放到WPF应用程序中 - Drag'n'drop files from (e.g.) iPhone in Windows Explorer onto a WPF application C# WPF - 将远程文件拖放到 Windows Explorer - C# WPF - DragDrop a remote file to Windows Explorer 如何构建可以在窗口之间拖放用户控件的 WPF 应用程序? - How do I build a WPF application where I can drag and drop a user control between windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM