63

Using Visual studio 2010 I got problems when double-clicking, for example a config file (*.config). Visual Studio would open but give me a error message about parameters. If I simple try to drag and drop a file that Visual Studio usually can read in to it, the icon will give me the "not possible icon"?

I have now installed Visual Studio 2012 and it has the same problem?!

This makes my work a lot harder, it should be easy to just drag & drop files into Visual Studio, but it's not so? Now I have to manually find the file with the file menu?

Please note, I have re-installed the computer before installing Visual Studio 2012.

MAXE
  • 4,978
  • 2
  • 45
  • 61
Banshee
  • 15,376
  • 38
  • 128
  • 219
  • I dunno about you, but I seem to be able to drag and drop just fine. The only problem being that the files are not copied in, they are simply linked as resources. – Games Brainiac Mar 05 '13 at 15:10
  • possible duplicate of [Can't drag files to Solution Explorer](http://stackoverflow.com/questions/267323/cant-drag-files-to-solution-explorer) – KyleMit Oct 13 '14 at 15:40

9 Answers9

86

On Windows Vista and newer Windows Explorer runs with medium integrity level. If you run Visual Studio as administrator (high integrity level) then for security reasons OS will disable drag and drop from Explorer to Visual Studio.

You can either run Visual Studio as normal user or you can install VSCommands for Visual Studio 2012 extension. It has several features that can help with this such as:

  • Elevated Windows Explorer - small tool which looks like Windows Explorer but runs with elevated permissions allowing Drag And Drop
  • Directory Explorer - tool window inside Visual Studio which again looks like Windows Explorer and allows Drag And Drop
  • Run Visual Studio with medium integrity - allows Drag And Drop from Windows Explorer, but you won't be able to attach to processes run by other users (e.g. IIS)
user503386
  • 1,108
  • 8
  • 5
  • Thanks, I have installed Visual VSCommands for Visual Studio 2012 but can´t find any elevated Windows Explorer? – Banshee Mar 05 '13 at 15:39
  • It is under Tools - VSCommands in main menu. You can also press Ctrl+Q in Visual Studio to go to Quick Launch and type word 'eleavated' there. – user503386 Mar 05 '13 at 15:44
  • hmm I was hoping to solve that you could drag drop things from all over Windows but this only opens a special windows where you will have to locate the file just as if you go Arkiv>Open file. – Banshee Mar 06 '13 at 08:13
  • My solution contains a Windows Service that starts WCF services and to do this it needs amdin rights. – Banshee Mar 06 '13 at 08:19
  • If you don't have to attach to processes run by other users than you can try starting VS with medium integrity level (Tools - VSCommands - Options - IDE Enhancements - General, tick Always start with elevated permissions and start with medium integrity, restart VS). Otherwise there's nothing more you can do because this is OS limitation :( – user503386 Mar 06 '13 at 10:33
  • I think the easiest way around this is not to run in Administrative mode. Unfortunately, that's the easiest way to avoid having to configure permissions and things for already running websites... The effect is often that you can either a) attach to a running process or b) drag and drop, but not both, without a restart (as, by default, gaining administrative priv's requires VS2012 restart...) – Sprague Aug 09 '13 at 10:50
  • 43
    This is an anti-feature and it needs to be fixed. Files need to be dragged and dropped everywhere all the time, without a mythical magical bind step. Having this broken in the IDE is totally unacceptable. This is bad and the MS developers who wrote this POS should feel bad. – ggb667 Nov 10 '14 at 18:25
  • 4
    http://stackoverflow.com/questions/20402772/drag-drop-files-into-visual-studio-doesnt-work – Zakos Dec 06 '14 at 15:43
  • Thanks, I am using **visual studio 2015 community edition**, it was not allowing me to drag and drop because i was running it with administrator rights, i closed and again opened without administrator rights and it allowed drag and drop. – Ariven Nadar Jan 16 '17 at 13:15
  • From the link Zakos gave: Control Panel => Administrative Tools => Local Security Policy and under Security Settings => Local Policies => Security Options change Accounts: Administrator account status to enabled and UAC: Run all admins in Admin Approval Mode to disabled. – jimnkey Sep 05 '21 at 04:59
39

If you run VS as administator, instead drag n drop, do copy (either ctrl+c, context menu "copy") the file selection in explorer and paste (ctrl+v, context menu) on selected node in VS

daniel
  • 644
  • 6
  • 5
19

This was driving me nuts. In my Visual Studio solution I have two Web Application which use IIS as web server so because of this I have to always start my Visual Studio in Administrator mode. After starting as Admin I wasn't able to drag and drop files from Explorer to Visual Studio.

Solution:

  1. Open Command Prompt as Administrator (Shortcut for Windows 8.1 is ⊞ Win + X + A)
  2. Type "explorer" this would open Windows Explorer with Admin privileges.

CMD Admin

And now you should be able to drag and drop any file from explorer to Visual Studio

Drag n' Drop

Community
  • 1
  • 1
ndd
  • 3,051
  • 4
  • 25
  • 40
  • I am happy to correct mistake/inaccuracy in answer so please leave reason for downvoting :) that way others will also benefit and it will improve answer. – ndd Oct 13 '15 at 12:44
  • When I try this approach in Windows 10 it doesn't solve the problem for me. When looking in the task manager I see that this approach didn't result in giving explorer.exe elevated privs in Windows 10. – RonC Sep 06 '17 at 15:04
  • @RonC This thread may help - https://superuser.com/a/1060578 for Windows 10 – ndd Sep 07 '17 at 17:32
  • I ended up creating a Windows 10 specific question here: https://stackoverflow.com/questions/46076093/drag-and-drop-into-visual-studio-2017-running-on-windows-10-does-not-work and the the person who created that superuser.com post is the one that answered it :- ) (citing the same post) It did solve my problem after a bit of back and forth. – RonC Sep 07 '17 at 17:36
10

If you disable UAC completely you can drag & drop from anywhere again. To do this you can't use the slider in the Control Panel because that only brings the UAC level down to 1. Make this registry change, reboot, and you can again use your computer like god intended.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLUA"=dword:00000000
Mike
  • 411
  • 3
  • 8
8

I think the main goal of this question is how to add many folders and files to your project in a comfortable way. Drag and Drop files into your project is one solution, which fails under certain circumstances.

Another very easy way is:

  • Copy the new folders and files where you physically want them in your project
  • Open the project explorer in VS and click the button "Show all files"
  • All the folders and files, which are now not part of your project yet appear white
  • Select the the white folders or files, right-click and choose "Bind to project"
  • Done

This is also possible, if you run VS as admin.

Have some fun!

By the way: I found this question, because I had the same issue with drag and drop. I understand the security issues, but it is an annoying feature.

Michael
  • 938
  • 1
  • 10
  • 34
5

I'm using this easiest approach. When you run Visual Studio in Administrator Mode. When you need to drag and drop, just press CTRL+O to open up a file browser within visual studio, and use that file browser as an Elevated Explorer to do your drag and drop.

Richie86
  • 169
  • 1
  • 4
  • Why? This doesnt solve the problem of not being able to drag and drop. The problem wasnt that he's unable to use the open file dialogue. – nights Oct 18 '18 at 03:12
  • 2
    @nights you misunderstand something? – Richie86 Oct 19 '18 at 05:56
  • Sorry, I don't think that's an answer. Equally, I could print out the file and tack it over my computer monitor. Really good resolution. But doesn't answer the question :) – noelicus Dec 04 '18 at 10:24
  • @noelicus you did miss something. What Richie is saying is quirky but *works*!. CTRL + O to open a file explorer. Go to the folder with the file you want to add. OK now the weird part. Don't click "OK" or "Cancel". Right then, drag from the CTRL + O window and drop into Visual Studio. it works. – Don Cheadle Jun 28 '19 at 02:23
  • @Richie86 you need to edit this answer to be more clear how it allows a drag and drop into VS. As it stands, it doesn't immediately read like a valid answer. – Don Cheadle Jun 28 '19 at 02:26
  • You're right I didn't get that, but it still doesn't answer the question or save any time etc. I know I can browse for a file; I know I can print a file and stick it on my monitor. What saves time is having a folder open and dragging across into VS. If I'm opening the browse I may well just browse. Why drag and drop? Appreciate you adding the clarification though. – noelicus Jun 28 '19 at 20:49
2

I had a similar problem but my issue was a bit different. I was trying to drag and drop a file from inside a zipped folder. Once I unzipped the folder drag & drop started working again.

Andrej Grobler
  • 544
  • 6
  • 5
1

I had this problem as well because I was opening VS in admin mode and the file explorer by default is not in admin mode.

Ended up creating a PowerShell and bat script to start explorer in admin mode every time the computer start.

admin.bat file:

@ECHO OFF
PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""%~dpn0.ps1""' -Verb RunAs}"

admin.ps1 file:

taskkill /f /im explorer.exe
start-process explorer.exe

The files just have to be in the same folder. Doesn't matter what they are called. Run the .bat file to restart explorer in admin mode or just create a shortcut to the .bat file in the startup folder ;) the script and ps1 file can be hidden.

MAXE
  • 4,978
  • 2
  • 45
  • 61
stibay
  • 1,200
  • 6
  • 23
  • 44
  • This approach doesn't work for me in Windows 10. After running this, when I check task manager explorer.exe still doesn't have elevated privs. – RonC Sep 06 '17 at 15:11
  • You must have the registry tweak, and even then this does not work in Windows 10. Leave the `taskkill` out. Only running `explorer.exe` in an admin cmd prompt works. Or `start-process explorer.exe` or `start-process explorer.exe -Verb runAs`. And the result is just that one window has admin rights. Windows-E will open non-admin. – RobG Sep 29 '17 at 02:24
0

On windows 8.1, change the registry key: Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA and set value = 0.

sphinks
  • 3,048
  • 8
  • 39
  • 55
Mourad
  • 1
  • 2