Visual Studio does not let me drag drop items into it?
Asked Answered
C

9

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.

Calices answered 5/3, 2013 at 14:41 Comment(2)
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.Orling
possible duplicate of Can't drag files to Solution ExplorerSemaphore
H
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)
How answered 5/3, 2013 at 14:54 Comment(10)
Thanks, I have installed Visual VSCommands for Visual Studio 2012 but can´t find any elevated Windows Explorer?Calices
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.How
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.Calices
My solution contains a Windows Service that starts WCF services and to do this it needs amdin rights.Calices
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 :(How
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...)Scissors
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.Kesselring
#20403272Dewees
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.Lepton
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.Carmencarmena
V
40

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

Varix answered 31/1, 2014 at 18:3 Comment(4)
and that's the simplest approach !Shelleyshellfire
Pathetic that it's required, but it works in VS2017, thanks for the workaround.Gutbucket
Salaam +1 Worked In VS 2019 Thank YouSodium
Worked In VS 2022 Preview Version 17.8.0 Preview 2.0Authenticity
S
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

Sextant answered 5/9, 2014 at 20:46 Comment(4)
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.Sextant
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.Popularize
@Popularize This thread may help - superuser.com/a/1060578 for Windows 10Sextant
I ended up creating a Windows 10 specific question here: #46076593 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.Popularize
C
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
Chosen answered 17/5, 2015 at 0:6 Comment(1)
"Like god intended"? Indeed!Cornew
C
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.

Carrissa answered 17/9, 2013 at 18:29 Comment(0)
R
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.

Rumple answered 12/11, 2017 at 15:14 Comment(6)
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.Pustulant
@Pustulant you misunderstand something?Rumple
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 :)Schouten
@Schouten 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.Hackler
@Rumple 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.Hackler
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.Schouten
D
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.

Doe answered 7/1, 2014 at 9:45 Comment(0)
F
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.

Finochio answered 28/1, 2016 at 11:47 Comment(2)
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.Popularize
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.Farina
E
0

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

Endgame answered 5/2, 2016 at 13:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.