private void listBox1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
//already validated the format in the dragover event, no need to check again...
//the data type will be a string array, because you could drop multipal files
string[] file = (System.String[])e.Data.GetData(DataFormats.FileDrop,true);
//add the files
foreach(string s in file)
{
listBox1.Items.Add(s);
}
}
private void listBox1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
//inform the user that he can drop the data in the listbox, if file/s are dropped
if(e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
}