Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an existing directory tree to a project in Visual Studio?

The issue is simple really. Instead of creating folders in Visual Studio, I create a directory structure for my project on the file system. How do I include all the folders and files in a project, keeping the structure?

If I "Add Existing File" on a folder named Services and navigate to a file in the directory structure .. Services > AccountManagement > CreateAccount.cs, it appears in Visual Studio like so: Services > CreateAccount.cs. I do not want this.

I have an entire directory structure worked out already, as I am mimicking our client developers using the same structure for organization. How do I add all the folders and files to the project in Visual Studio? Or do I have to do what most Microsoft users do and "put up with it" and recreate each and every folder through Visual Studio?

like image 292
Brian Leahy Avatar asked Dec 25 '08 03:12

Brian Leahy


People also ask

How do I add an existing directory to a solution in Visual Studio?

Right click the project or contained folder and choose Add | Existing Item... . Use Show All Files . Click on files or folders you would like to add to the project and choose Include In Project . Drag and drop files and folders from Windows Explorer.

How do I add an existing item in Visual Studio?

You can easily do this from Visual Studio by right clicking the project you want to include it in, and selecting Add > Existing Item… You're then presented with a file picker dialog, so you can navigate to the file, and choose Add.


2 Answers

You need to put your directory structure in your project directory. And then click "Show All Files" icon in the top of Solution Explorer toolbox. After that, the added directory will be shown up. You will then need to select this directory, right click, and choose "Include in Project."

enter image description here

enter image description here

like image 152
Gant Avatar answered Sep 25 '22 06:09

Gant


You can also drag and drop the folder from Windows Explorer onto your Visual Studio solution window.

like image 44
Todd Smith Avatar answered Sep 21 '22 06:09

Todd Smith