Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I have a simple application in C#.net on which i may drop any file from explorer and it shows the file link.
using this code
C#
private void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Copy;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }
private void Form1_DragDrop(object sender, DragEventArgs e)
        {
            Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
            if (a != null)
            {
                string s = a.GetValue(0).ToString();
                MessageBox.Show(s);


            }

        }


But when I run this application as an administrator. The application stops dropping the files. And and mouse arrow changes looks like file drop is not allowed appears instead of file copy arrow on the form.

How may I solve it? I want to enable drop in any condition. either app is running in as administrator or normal user.

Any one if help on this.? Or any workaround will be highly appreciated.
Thank you.
Posted
Updated 20-Feb-14 9:33am
v3
Comments
Sergey Alexandrovich Kryukov 20-Feb-14 14:09pm    
Never heard of such things. What is "round slash"? Anyway, I think there is not enough information to sort it out.
—SA
Asad Nawaz 20-Feb-14 14:20pm    
That below symbol is a round slash.
Ø
Sergey Alexandrovich Kryukov 20-Feb-14 15:19pm    
You report was too misleading. I though it's "empty set", but it is not, and not "round slash", of course.
This is 00D8, "Latin Capital Letter O With Stroke". You could find it out by yourself, because it's easier on your side.

And sorry, your information is not enough to help you.

—SA
Asad Nawaz 20-Feb-14 15:34pm    
changed the description.
now more descriptive

1 solution

You can't solve it. It's a HUGE security violation to allow interaction between non-priviledged and priviledged processes. By allowing this, you're essentially giving the non-admin process (the Desktop) more priviledges than allowed by the users login.
 
Share this answer
 
Comments
Asad Nawaz 20-Feb-14 14:26pm    
My purpose is to just get the link of that file that is just dragged on the form. I want the link on both ways either privileged or non privileged.
Do you have some work around?
Dave Kreskowiak 20-Feb-14 15:27pm    
What did I say in my post?? There is no way to do it because it's a HUGE security violation.

You specifying a reason to me that "it's just this little thing" is not going to convince Microsoft or Windows to let that happen!
Sergey Alexandrovich Kryukov 20-Feb-14 15:32pm    
For a record: this is not 100% accurate.

Let me give you one example. I run file manager instances using standard OS Shell API, one with elevated privileges, another is not.
First of all, you certainly can drop file from privilege-elevated instance to another, if the source file is accessible in both, as well as target directory. Note that no OS security protection prevents that. Now, what if the source file is accessible to privilege-elevated instance and not to another instance. Apparently, you still could copy it to some accessible directory, using privilege-elevated instance along. And non-elevated instance could later access it. There is nothing wrong with it. But what happens if you try to drag-n-drop such file? Very logical thing: the copy command is shown, but, upon user's confirmation, the non-elevated instance reports that the source file is inaccessible. Isn't it logical? Isn't it safe.

It looks like in reality the system (I am talking about Windows 7 here) behave safely but is more reasonable and less restrictive than you tried to present here. Drag-n-drop between privilege-elevated and regular process is quite legitimate and does not effectively elevate privileges of the non-elevated process.

—SA
Dave Kreskowiak 20-Feb-14 15:41pm    
Every way I've tried dragging and dropping works except the one where you try to drag from a non-elevated to an elevated process. Dragging from an elevated to a non-elevated process works as epxected.

Granted, I didn't dig into it for very long, but I could never get it to work dragging from non-elevated to elevated.
Sergey Alexandrovich Kryukov 20-Feb-14 16:07pm    
It depends on what you are doing and how. Not being able to drop anything between such processes is not a rule.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900