How do I drag and drop a folder in Winforms?
- by Tuntuni
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.