//設置Form的AllowDrop為true
2
3 private void Form1_DragDrop(object sender, DragEventArgs e)
4 {
5 string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
6 MessageBox.Show(path);
7
8 }
9
10 private void Form1_DragEnter(object sender, DragEventArgs e)
11 {
12 if (e.Data.GetDataPresent(DataFormats.FileDrop))
13 e.Effect = DragDropEffects.Link;
14 else e.Effect = DragDropEffects.None;