Drag & Drop - Order of files/folders when multiple selection

H

Hartmut Dippon

Hi all,

I hope somebody can help me with following problem:

I have an application where I can drag&drop files/dirs from within explorer
onto my form.

If multiple files/dirs are selected I can see that the order I get in my
drop event is not always the same as displayed in the explorer window.
Further more the order changes depending on how many files/dirs are
selected. It looks like a 'random' order to me.

Is there any possibility within C#/.NET 2.0/3.0 to detect the file order
depening on the order the files/dirs were selected in the explorer window?

Many thanks in advance for any help!

Hartmut
 
O

Oliver Sturm

Hello Hartmut,

I don't think there's a way to do that - although I'm not exactly sure for
which order you're asking:
... the order ... is not always the same as displayed in the explorer
window.
... detect the file order depening on the order the files/dirs were
selected ...

This sounds like two different things to me - the order that is shown in
Explorer vs. the order in which files were selected. As far as I remember,
the order of file/dir info being passed in would actually be the same as
the order in which they were selected, but I could be wrong - in any case
I don't think that this is part of the spec, and so I wouldn't rely on it.


Oliver Sturm
 
H

Hartmut Dippon

Hello Oliver,

thanks for that reply.

I did some debugging to see the order I get in my drag & drop event compared
to the order the files/dirs are selected. However I cannot see any rule as
when I select multiple files/dirs (not just 2, but e.g. 10) I do not get the
entries in the order of files/dirs in explorer and also not in the order the
files/dirs are selected. Mybe it's the order the files/dirs are stored in
the file system.

So I think to let a user pick the order I always need to provide a list of
selected files/dirs where a user can rearange the files/dirs. This is
exactly what I wanted to avoid.

Hartmut
 
P

Peter Duniho

I did some debugging to see the order I get in my drag & drop event
compared to the order the files/dirs are selected. However I cannot see
any rule as when I select multiple files/dirs (not just 2, but e.g. 10)
I do not get the entries in the order of files/dirs in explorer and also
not in the order the files/dirs are selected. Mybe it's the order the
files/dirs are stored in
the file system.

My recollection is that Windows Explorer multi-file select goes something
like this:

1) Files are added to the file list LIFO. The most recently selected
file is first in the list.
2) When selecting more than one new file at a time (drag-rect,
shift-select a list, etc), the group is in order according to how they
appear in Windows Explorer, but the whole group is added at the front of
the selection
3) Clicking the final selection may result in one file (the file you
clicked to represent the whole group) being moved to the beginning of the
selection list

Of course, as Oliver notes there is no (as far as I know) documented
specification as to multi-select behavior for Windows Explorer. That is,
even if the above recollection is accurate, it should not be depended on.
It could change at any time.
So I think to let a user pick the order I always need to provide a list
of selected files/dirs where a user can rearange the files/dirs. This is
exactly what I wanted to avoid.

I'm not sure what it was you expected. Most applications that involve
themselves in lists of files generally do not depend on the files being in
any specific order. In those cases, they almost always simply display the
files in alphabetical order. In applications where order does matter,
since there is no way to guarantee that the user is necessarily going to
add the files in the right order in the first place, a UI to allow the
order of the files to be changed is always included. This is the
user-friendly thing to do.

If your application processes the filenames in some specific order, and
the order is important, I'm curious to know what your expectation of the
user specifying the order would have been? Was it your thought that the
user would be required to understand that the order in which they select
the files in Windows Explorer is important and results in an immutable
order in your own application? If so, I'd suggest that's not a very
user-friendly method of defining the order. If not, then it seems to me
that either you can reorder the files in your application (alphabetically,
for example, but any repeatable, predictable, documented method would be
fine), or you can allow the user to reorder the files manually, or both
(personally, if order matters, I'd recommend doing both).

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top