First set 'Allow Drop' to True
Next, add events for
// Only
allow drop if the item is a Directory
private void
textBoxPath_DragOver(object sender,
DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files != null
&& files.Length > 0 && Directory.Exists(files[0]))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void
textBoxPath_DragDrop(object sender,
DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files != null
&& files.Length > 0 && Directory.Exists(files[0]))
textBoxPath.Text = files[0];
}
Comments
Post a Comment