I want to allow the deletion of image files in my application: users can drag and drop images from Windows and transfer them to my window. I have the following code, but it seems like it is not working. I tried both FileDrop, and Bitmapboth failed
private void Border_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effects = DragDropEffects.Copy;
} else {
e.Effects = DragDropEffects.None;
}
}
private void Border_Drop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
MessageBox.Show(e.Data.GetData(DataFormats.FileDrop).ToString());
}
else
{
MessageBox.Show("Can only drop images");
}
}
How can I check which formats the user is trying to delete?
source
share