我在我的代码中设置了两个事件,Drag_Drop和Drag_Event,每当我尝试将某些内容拖入表单时,就会出现“带有直线的圆圈”符号。有趣的是,我在另一个项目中使用了相同的确切代码,并且它工作得很好。我注册了活动和一切。这是我的代码:
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (toSaveIcon)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
}
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
if (toSaveIcon)
{
string[] filePath = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string path in filePath)
{
icon = Icon.ExtractAssociatedIcon(path);
Debug.WriteLine("Icon saved successfully");
}
}
}
答案 0 :(得分:1)
有趣的是,我在另一个项目中使用了相同的确切代码,并且它运行得很好。
之前我遇到过这个问题,我通过以普通用户身份运行Visual Studio来修复它。如果您从visual studio运行,请确保它不是Administrator
。
您也可以直接从bin
文件夹运行该应用,您将有更好的主意。