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?


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."

在这里输入图像描述


您也可以将文件夹从Windows资源管理器拖放到Visual Studio解决方案窗口中。


Copy & Paste .

To Add a folder, all the sub-directories, and files we can also Copy and Paste. For example we can:

  • Right click in Windows explorer on the folder, and Copy on the folder with many files and folders.

  • Then in Visual Studio Solution explorer, right click on the destination folder and click paste.

  • Optional add to TFS; Then in the top folder right click and check in to TFS to check in all sub-folders and files.

  • 链接地址: http://www.djcxy.com/p/19054.html

    上一篇: 如何在Visual Studio中禁用ReSharper并再次启用它?

    下一篇: 如何将现有的目录树添加到Visual Studio中的项目中?