عند سحب بند (مسار مجلد) من listBox1 وإفلاته ضمن pictureBox1 يُحذف المجلد ويُحذف البند من listBox1، وإلا تظهر رسالة "المجلد غير موجود". اكتب إجراء حدث الإفلات.
أظهر إجابة سلّم التصحيح
private void pictureBox1_DragDrop(object sender, DragEventArgs e)
{
if (Directory.Exists(listBox1.SelectedItem.ToString()))
{
Directory.Delete(listBox1.SelectedItem.ToString(),true);
listBox1.Items.Remove(listBox1.SelectedItem.ToString());
}
else
{
MessageBox.Show("المجلد غير موجود");
}
}
{
if (Directory.Exists(listBox1.SelectedItem.ToString()))
{
Directory.Delete(listBox1.SelectedItem.ToString(),true);
listBox1.Items.Remove(listBox1.SelectedItem.ToString());
}
else
{
MessageBox.Show("المجلد غير موجود");
}
}