c# - 在管理员帐户中运行 Visual Studio 时无法触发拖放事件

标签 c# winforms drag-and-drop administrator

我使用 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 开始,由于用户界面权限隔离,您无法从运行在较低完整性级别的应用程序拖放到运行在较高级别的应用程序。”

参见http://blogs.msdn.com/b/patricka/archive/2010/01/28/q-why-doesn-t-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi.aspx了解详情

附注引用重复的评论也是正确的。

关于c# - 在管理员帐户中运行 Visual Studio 时无法触发拖放事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17416765/

相关文章:

c# - 在c#中的每个打印页面中打印页码

jquery - 使用 jQuery 拖放时保留元素的副本

swift - Spring 加载 NSOutlineView 叶行

c# - Entity Framework 的奇怪行为

c# - 使用 ASP.Net 获取和显示 RSS 提要

c# - 如果用户在文本框中键入内容或以编程方式调用 myTextBox.Text,如何确定是否触发了 "TextChanged"事件

javascript - 将 CSS 应用于正确放置的字母

c# - linq投影元素计数

c# - WPF:如何只从文本框中获取时间?

c# - 工具提示中的超链接