DataFormats.FileDrop Problem when dropping from explorer

From: MikeWorkflow (MikeWorkflow_at_discussions.microsoft.com)
Date: 12/20/04


Date: Mon, 20 Dec 2004 10:45:05 -0800

Hi all,

I've run into a problem that seems to be outside the realms of my code.
Basically, I'm just doing a simple drag and drop handler for the
DataFormats.FileDrop type. Very simply, I just grab the string array
containing the paths to the files I want.

This is all very very easy, but recently I noticed this little anomaly: If
you drag and drop from Windows Explorer, using the List or Detail view, the
results you get from the IDataObject are not in the correct order! If you
switch your Explorer view to any view other than List or Detail, the files
are in the correct order.

Furthermore, the order they show up in List or Detail seems to be different
each subsequent drop.

Of course, the order of the files is very important to me.

I am running Windows XP Professional, SP2. .NET Framework 1.1 (no SP1).

You can try to replicate this problem by creating a new C# Windows
Application and add a single text box called txtOutput. Set txtOutput's
AllowDrop property to true, Multiline to true, and add the following event
handlers:

txtOutput.DragDrop += new DragEventHandler(txtOutput_DragDrop);
txtOutput.DragEnter += new DragEventHandler(txtOutput_DragEnter);

Then drop the following two methods into your code:

                private void txtOutput_DragEnter(object sender,
System.Windows.Forms.DragEventArgs e)
                {
                        if(e.Data.GetDataPresent(DataFormats.FileDrop))
                                e.Effect = DragDropEffects.Copy;
                }

                private void txtOutput_DragDrop(object sender,
System.Windows.Forms.DragEventArgs e)
                {
                        string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
                        
                        foreach(string s in droppedFiles)
                                txtOutput.Text += String.Concat(System.IO.Path.GetFileName(s),"\r\n");
                }

Compile and run your application. Now, open Windows Explorer to a folder of
your choice. Try dragging and dropping a specific selection of files in
various Explorer views. You should see the same symptoms I described above.
If you don't, then I apologize for taking your time :p.

Can anyone give me insight as to why this is happening, and how to work
around it (other than instruct my customers that they can't operate in List
or Detail view)?

Thanks,
Mike



Relevant Pages

  • Re: deleting file in my pictures folder
    ... Every time I drag and drop files from Windows Explorer into my external hard drive folder - I get multiple copies of each file - but not every file I copied - only some of them. ... highlight the first file in the series and then hold down the Shift key and highlight the last file in the series. ...
    (microsoft.public.windowsxp.basics)
  • Re: Drag and drop document links into custom IDropTargets
    ... > called XYZ from lotus notes client 6.5 to Windows explorer, ... > works with most of the other drag & drop formats (i.e. ... > this particuler drag/drop format? ...
    (microsoft.public.win32.programmer.ole)
  • Re: delete file: Access to the path X is denied
    ... To delete this file you need to list processes and check who is hold the handler of this file, ... process) and a text file that I created in Windows Explorer. ... public static extern bool RemoveDirectory(string lpPathName); ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I drag pictures straight into Word 2000?
    ... Free Word eBook: http://www.mousetrax.com/books.html ... I used to be able to drag ... >a picture straight from Windows Explorer into a Word document (open both ...
    (microsoft.public.word.docmanagement)
  • Re: SAVING Microsoft WORD file as webpage - looks like crap after loading to website
    ... In Windows Explorer browse to the Word document. ... Drag the document from Windows Explorer onto the page. ... >I have been saving various MS WORD documents as WEBPAGES, ...
    (microsoft.public.frontpage.programming)