msdn.microsoft.com
https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.dragdropeffects?redirectedfrom=MSDN&view=netframework-4.7.2
//代码如下:--------------------记得把form1的allowdrop改成true
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string str1 = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
Process.Start(str1);
}
}
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.All;
}
else
{
e.Effect = DragDropEffects.None;
}
}
}