55

Is there a way to add existing Folders to a Visual Studio Project so that I do not have to do this file by file?

Edit

To make it clear: I want to add references not copies.

ouflak
  • 2,314
  • 4
  • 33
  • 42
HerpDerpington
  • 2,365
  • 3
  • 22
  • 38
  • 2
    It seems that it [http://stackoverflow.com/questions/57776/how-to-add-existing-item-an-entire-directory-structure-in-visual-studio](http://stackoverflow.com/questions/57776/how-to-add-existing-item-an-entire-directory-structure-in-visual-studio) is what you are looking for. – Evgeny Timoshenko Nov 17 '13 at 16:36
  • @johny this would add copies, wouldn't it? – HerpDerpington Nov 17 '13 at 16:43
  • also you may have a look at this post http://stackoverflow.com/questions/3610845/add-as-link-for-folders-in-visual-studio-projects – Evgeny Timoshenko Nov 17 '13 at 17:04
  • @HerpDerpington if my answer helps, you can mark it as accepted answer :) – DevLoverUmar Dec 23 '20 at 13:06

11 Answers11

176

If the folder and its contents have already been created and it physically exists under the Project, you can click the Show All Files icon (at the top of the Solution Explorer windows) and then when the folder shows as a dotted icon, right-click it and choose Include In Project and the folder and all its contents are added.

John J Smith
  • 9,654
  • 9
  • 49
  • 69
32

VS 2019

Click on the 'Show All Files' icon at the top of Solution Explorer window.

'Show All Files' icon

Then the folders/files of the selected project will be displayed as dotted icons. You can right click any of them and select include in project to include them in the project.

For solution folders, click the 'Show All Files' icon then first exclude the desired folders/files and then include them.

DevLoverUmar
  • 4,509
  • 4
  • 27
  • 41
  • 1
    Of the different ways I've tried to add files and folder, this is the only way that seems to work without any fuss – Microbob Sep 19 '20 at 21:54
  • 1
    I've done this in previous versions of VS, too. For some reason, the "Show All Files" icon wasn't showing up for me in 2019, though. It took some fiddling with the Solution Explorer bar sizing for it to show up. IDK what it even took for it to appear, it just all of a sudden was there. – computercarguy Nov 02 '20 at 17:44
  • Great that there is this workaround but disappointing that add existing item violates the principle of least surprise. – Paul McCarthy Jan 08 '21 at 14:00
  • 1
    I had a situation where I couldn't see the include or exclude in folder options. They came back as soon as I rebooted VS2019. Thanks! – JWP Mar 01 '21 at 04:55
  • 1
    this is helpful, or at least works for my needs. Thanks! – Tabrock Mar 18 '21 at 16:20
  • Pleasure ... :) – DevLoverUmar Mar 18 '21 at 16:20
13

You could open Add Existing Item dialog, select a bunch of files, click on Add's button drop-down menu and choose Add as a link. It will add files as references and won't copy them.

Evgeny Timoshenko
  • 2,561
  • 4
  • 29
  • 49
13

You can drag and drop the entire folder. If all files don't show you can repeat the drag'n'drop procedure for subfolders.

kburnik
  • 191
  • 2
  • 6
  • 1
    You can also copy external folders in file explorer and paste it in visual studio project explorer. – Zeni Apr 12 '16 at 06:54
  • this should be the correct answer, as the other answer doesn't entail how you would create the folder, if it is already there it will complain about there already being a folder there. – thekevshow Nov 03 '16 at 19:10
7

I don't think there is, but if you have all the files in one folder, you can add multiple files in one go. Just mark them all in the add file dialog.

nvoigt
  • 61,531
  • 23
  • 73
  • 116
6
  1. right click the project, and choose "New Solution Explorer view", a window pops up.
  2. and then form the toolbar of the new window ("solution explore window"), you click the "Show All Files" icon.
  3. then include the folders of interest into your project...
Jim L
  • 2,187
  • 16
  • 20
user9352585
  • 61
  • 1
  • 1
3

In Visual Studio 2019 I could not drag and drop from file explorer or 'Show All Files' and then add them. Instead, while in File Explorer, right click and choose copy, then click on the location within Visual Studio 2019 and right click and choose paste. All of the files in the folder and subfolders will be added.

th3morg
  • 3,782
  • 28
  • 44
2

If you're working in VS 2019 Community Edition, I find that you can:

  1. Open the parent folder of whatever folder you're trying to add in windows explorer
  2. Right-click and copy that folder
  3. Go to the solution explorer in visual studio
  4. Right-click then paste the folder wherever you want to in the solution tree
elersong
  • 646
  • 2
  • 11
  • 25
1

If the folder and its contents have already been created and it physically exists under the Project then click on view over the project enter image description here then you can see all folders and files and you just need to copy files and click on solution in the same folder view and paste all in there

1

It has been a while since this was originally posted, but here is an alternative answer for a solution folder that is NOT inside of a project. If you only care to be able to look at the physical files from inside visual studio and do not necessarily require to see them in the solution explorer default view, then click on the switch view button and choose the folder view and any physical directory/directories that are under your solution root folder will appear here even if they do not appear in the solution explorer default view.

folder view

If however, you want to add a folder tree that isn't too large as a virtual solution directory/directories to match your existing tree structure, do that and and then "add the existing" physical files to the virtual directory/directories. If the physical directory exists in your solution directory it will not copy the files - it will link directly to the physical files but they will appear as part of the solution virtual directories.

C Post
  • 36
  • 4
  • 1
    Before you paste this in even more locations, please take the time to read [Is it acceptable to add a duplicate answer to several questions?](https://meta.stackexchange.com/questions/104227/is-it-acceptable-to-add-a-duplicate-answer-to-several-questions). – fcdt Sep 30 '20 at 18:10
0

Check whether that folder is inside project folder or not, if yes:

  1. click Show All files in solution explorer.

  2. now you can see folder name in solution explorer. right click the folder -> Include In Project.

  3. If the folder out of project please copy it into the project directory in the place where we want it.

notescrew
  • 3,072
  • 4
  • 21
  • 36