How can I add whole folder and its subdirectories in a visual c++ project? I am using visual studio 2010 professional. I mean you can add files by using Add Existing Item
but how do you add a whole directory?
Asked
Active
Viewed 1.6k times
6

MetallicPriest
- 29,191
- 52
- 200
- 356
-
Don't think you can. You need to add the source files (you can select multiple files) with "Add Existing Item"... – George May 14 '12 at 18:19
-
This is a tad off topic. You can add directories however you please in your project source directory and "Add Existing Item" still works by selecting all files in a sub-directory. You can add filters within your solution from Visual Studio which function as "virtual directories" to organize files in the explorer hierarchy regardless of actual folder structure on disk as well. – AJG85 May 14 '12 at 18:33
1 Answers
12
The quickest way that I know of is to
- add the folder to your project file directory using Windows Explorer
- find the folder in Solution Explorer (make sure Show All Files is checked)
- right click on the folder and select Include In Project
You may have to do the folder and the files separately, but you can select multiple files at once.

Les
- 3,150
- 4
- 29
- 41
-
1Iterates recursively and adds the files as a flat list. Wonderful... It's not on you but have to be stated. – Notinlist Jul 16 '15 at 13:33
-
1When I did this, it did add it to the project, but it still does not show up in the solution explorer, unless I click the "show all files" button. I would like the folder to be visible even when "show all files" is turned off. If it makes a difference, I'm using a Raspberry Pi "Blink" solution template. – wryan Jan 01 '19 at 22:44
-
@wryan if you want the files to be grouped in the Solution Explorer group such that they appear to be in a folder, I think you want to add a new "filter" (right-click project, Add>New Filter). Then you drag and drop the files in the Solution Explorer view into that filter. – 23r0c001 Jun 17 '23 at 00:28