致谢
private void Form1_Load(object sender, EventArgs e)
{
listBox_Files.AllowDrop = true;
}
private void listBox_Files_DragDrop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
listBox_Files.Items.Add(file);
}
private void listBox_Files_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy;
}