Click to See Complete Forum and Search --> : Drag and drop files from my app to Explorer
bewa
January 27th, 2005, 05:12 AM
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.
bewa
January 28th, 2005, 06:38 AM
C'mon... no-one knows? I'm stuck here.... :(
Otto Drunkencoder
January 28th, 2005, 06:59 AM
What is Windows Explorer supposed to do with the dropped objects ?
bewa
January 28th, 2005, 07:28 AM
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):
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...
bewa
January 28th, 2005, 08:42 AM
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....
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 );
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.