How do I drag and drop a folder in Winforms?
Posted
by
Tuntuni
on Stack Overflow
See other posts from Stack Overflow
or by Tuntuni
Published on 2012-06-27T15:07:59Z
Indexed on
2012/06/27
15:16 UTC
Read the original article
Hit count: 205
I would like to know how to drag & drop the folder and get its name. I already know how to do it with a file, but I'm not really sure how to modify it to be able to drag folders as well. Here's the code of the event that is triggered when a file is dropped.
private void checkedListBox_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
//I'm only interested in the first file, even if there were multiple files
//dropped
string fileName = ((string[])e.Data.GetData(DataFormats.FileDrop))[0];
}
}
Thanks, Tuntuni.
© Stack Overflow or respective owner