Question

I use Visual Studio 2008, .net framework 3.5

I have an webservice application (a winform client which is using webservice), and I have to run it in Administrator account

I need to drag and drop files from windows explorer to a form of this application.

Here is my code:

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);
        }

    }

It works when I run in normal account, but in Administrator It doesn't. How to solve it?

Was it helpful?

Solution

This question was also raised here: Drag and drop not working in C# The answer is that "Starting from Windows Vista because of User Interface Privilege Isolation you cannot drag and drop from an application running at lower integrity level to an application which runs on a higher level."

See 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 for details

P.S. The comment referencing duplication is also correct.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top