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

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

问题描述:

问题其实很简单.我没有在 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?

如果我在名为 Services 的文件夹上添加现有文件"并导航到目录结构中的一个文件 .. Services > AccountManagement > CreateAccount.cs,它会在 Visual Studio 中显示如下:Services > CreateAccount.cs.我不要这个.

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.

我已经制定了一个完整的目录结构,因为我正在模仿我们的客户开发人员使用相同的组织结构.如何将所有文件夹和文件添加到 Visual Studio 中的项目?还是我必须像大多数 Microsoft 用户所做的那样忍受"并通过 Visual Studio 重新创建每个文件夹?

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