我使用 Visual Studio 2008、.net Framework 3.5
我有一个Web服务应用程序(一个使用Web服务的winform客户端),我必须在管理员帐户中运行它
我需要将文件从 Windows 资源管理器拖放到此应用程序的窗体中。
这是我的代码:
this.AllowDrop = true;
private void Form1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
e.Effect = DragDropEffects.All;
}
private void Form1_DragDrop(object sender, DragEventArgs e)
{
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
foreach (string s in fileList)
{
MessageBox.Show(s);
}
}
当我以普通帐户运行时它可以工作,但在管理员帐户中则不能。怎么解决?
最佳答案
这个问题也在这里提出: Drag and drop not working in C# 答案是“从 Windows Vista 开始,由于用户界面权限隔离,您无法从运行在较低完整性级别的应用程序拖放到运行在较高级别的应用程序。”
附注引用重复的评论也是正确的。
关于c# - 在管理员帐户中运行 Visual Studio 时无法触发拖放事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17416765/