CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2001
    Posts
    80

    Drag and drop files from my app to Explorer

    HI,

    I have found a zillion examples of how to do drag and drop from (as example) Windows Explorer to my Winform app, but none the other way. (My App to Explorer.)

    anyone who can help me with this? I'm using a listview to show files in my app and multiple file selection is allowed.

  2. #2
    Join Date
    Oct 2001
    Posts
    80

    Re: Drag and drop files from my app to Explorer

    C'mon... no-one knows? I'm stuck here....

  3. #3
    Join Date
    Aug 2004
    Posts
    33

    Re: Drag and drop files from my app to Explorer

    What is Windows Explorer supposed to do with the dropped objects ?

  4. #4
    Join Date
    Oct 2001
    Posts
    80

    Re: Drag and drop files from my app to Explorer

    Thanks for your reply...

    I have a listview of Filenames from somewhere on my disk. Now I want to be able to drag the file items from my listview to some directory i have open in Explorer, and then the files are copied from place a to place b.

    I have this code so far (testing code):

    Code:
        private void listView1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
          DataObject SelectedFiles = new DataObject(); 
         
          SelectedFiles.SetData( DataFormats.FileDrop, "c:\\comcheck.chm" );
           
          listView1.DoDragDrop( SelectedFiles , DragDropEffects.Move | DragDropEffects.Copy );
          
        }
    If I drag using this code, I get the cursur in Windows Explorer that it is ready to accept the drop, but nothing happens then...

  5. #5
    Join Date
    Oct 2001
    Posts
    80

    Re: Drag and drop files from my app to Explorer

    Got it working

    I don't know... seems like I've tried this same code, but now it works.... really weird.

    This is how to do it....

    Code:
    string [] files;
          files = new string[ 2];
      
          files [0] = "c:\\comcheck.chm";
          files [1] = "c:\\renamecomm.mdb";
    
                 
          DataObject dt = new DataObject ( DataFormats.FileDrop , files );
          listView1.DoDragDrop( dt , DragDropEffects.All );

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured