Visual Studio解决方案只指向一个文件夹并显示解决方案资源管理器中的所有子文件夹和文件?

时间:2023-01-16 21:51:05

Is there a way to create a blank solution, or some type of file-based project solution within Visual Studio so that I can point to a root folder, and have all of the sub-folders and files in that root, show up in my solution explorer? I realize I can create a blank solution and then add the individual items manually by add > existing item, however, this does not keep the folder structure intact, and, well, it would take forever if I have a lot of folders/files.

有没有办法在Visual Studio中创建一个空白解决方案或某种类型的基于文件的项目解决方案,以便我可以指向根文件夹,并在该根目录中显示所有子文件夹和文件,显示在我的解决方案探索者?我意识到我可以创建一个空白的解决方案,然后通过添加>现有项目手动添加单个项目,但是,这不会保持文件夹结构完整,而且,如果我有很多文件夹/文件,它将需要永远。

2 个解决方案

#1


4  

You can also create the blank solution and then click the second-from-the-right icon at the top of the solution explorer (it looks like three files with one "cut out"). Once you click that button to show the files in the solution directory that are not in a project, you can select all the files (with shift-click) and then right-click on your selection and select "Include In Project."

您还可以创建空白解决方案,然后单击解决方案资源管理器顶部的右起第二个图标(它看起来像三个文件,其中一个“切出”)。单击该按钮以显示解决方案目录中不在项目中的文件后,可以选择所有文件(按住Shift键单击),然后右键单击所选内容并选择“包含在项目中”。

Also note you can select multiple files in the "Add Existing..." file window with shift- or control-click.

另请注意,您可以使用shift或control-click在“Add Existing ...”文件窗口中选择多个文件。

#2


1  

You have to create a Visual Studio Project inside your solution to be able to add files with keeping their folder structure. The files to be added must reside below the project's main folder.

您必须在解决方案中创建一个Visual Studio项目才能添加文件并保留其文件夹结构。要添加的文件必须位于项目的主文件夹下。

I suggest adding a "C# Empty Project" (Solution Explorer: Solution > Add > New Project ... > Visual C# > Windows > Empty Project). After that you can proceed as described by SoloBold to show the files in the project folder. Right click on the topmost folder of your source files an select "Include In Project" and the whole folder structure including all files will be added. This may take some time depending on the number of files / subfolders.

我建议添加一个“C#Empty Project”(解决方案资源管理器:解决方案>添加>新建项目...> Visual C#> Windows>空项目)。之后,您可以按照SoloBold的描述继续显示项目文件夹中的文件。右键单击源文件的最顶层文件夹,选择“包括在项目中”,将添加包括所有文件的整个文件夹结构。这可能需要一些时间,具体取决于文件/子文件夹的数量。

See also: Answer to similar question, with screenshot

另请参阅:使用屏幕截图回答类似问题

#1


4  

You can also create the blank solution and then click the second-from-the-right icon at the top of the solution explorer (it looks like three files with one "cut out"). Once you click that button to show the files in the solution directory that are not in a project, you can select all the files (with shift-click) and then right-click on your selection and select "Include In Project."

您还可以创建空白解决方案,然后单击解决方案资源管理器顶部的右起第二个图标(它看起来像三个文件,其中一个“切出”)。单击该按钮以显示解决方案目录中不在项目中的文件后,可以选择所有文件(按住Shift键单击),然后右键单击所选内容并选择“包含在项目中”。

Also note you can select multiple files in the "Add Existing..." file window with shift- or control-click.

另请注意,您可以使用shift或control-click在“Add Existing ...”文件窗口中选择多个文件。

#2


1  

You have to create a Visual Studio Project inside your solution to be able to add files with keeping their folder structure. The files to be added must reside below the project's main folder.

您必须在解决方案中创建一个Visual Studio项目才能添加文件并保留其文件夹结构。要添加的文件必须位于项目的主文件夹下。

I suggest adding a "C# Empty Project" (Solution Explorer: Solution > Add > New Project ... > Visual C# > Windows > Empty Project). After that you can proceed as described by SoloBold to show the files in the project folder. Right click on the topmost folder of your source files an select "Include In Project" and the whole folder structure including all files will be added. This may take some time depending on the number of files / subfolders.

我建议添加一个“C#Empty Project”(解决方案资源管理器:解决方案>添加>新建项目...> Visual C#> Windows>空项目)。之后,您可以按照SoloBold的描述继续显示项目文件夹中的文件。右键单击源文件的最顶层文件夹,选择“包括在项目中”,将添加包括所有文件的整个文件夹结构。这可能需要一些时间,具体取决于文件/子文件夹的数量。

See also: Answer to similar question, with screenshot

另请参阅:使用屏幕截图回答类似问题