Visual Studio 和 C++:使用过滤器作为目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15677756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 19:38:43  来源:igfitidea点击:

Visual Studio & C++: Use filters as directories

c++visual-studiovisual-studio-2012solution

提问by bytecode77

I Use Visual Studio 2012 Professionaland C++. When creating so called 'filters' and adding source files to them, the files in the solution explorer are divided into sub directories, while on the file system they are all in the same directory (the project directory)

我使用Visual Studio 2012 ProfessionalC++。创建所谓的“过滤器”并向其中添加源文件时,解决方案资源管理器中的文件分为子目录,而在文件系统上,它们都位于同一目录(项目目录)中

Question:I want to add a file to a filter while at the same time adding it to the corresponding directory on the file system. How can this be accomplished other than manually moving files around?

问题:我想将文件添加到过滤器,同时将其添加到文件系统上的相应目录中。除了手动移动文件之外,如何实现这一点?

采纳答案by jt234

One alternative would be to switch to "Show All Files" in Solution Explorer top menu.

一种替代方法是在解决方案资源管理器顶部菜单中切换到“显示所有文件”。

This way you can move and manage files in folders.

这样您就可以移动和管理文件夹中的文件。

Filters will not get used though.

但是过滤器不会被使用。

回答by reloZid

The "Show All Files" solution did not work for me because in my case the source files were not located under the directory containing the project file.

“显示所有文件”解决方案对我不起作用,因为在我的情况下,源文件不在包含项目文件的目录下。

I finally ended up with writing a VS extension which allows you to organize either the filter structure inside the project or the file structure on the disk automatically by invoking a command through the context menu. I thought some of you might be interested in that extension too:

我最终编写了一个 VS 扩展,它允许您通过上下文菜单调用命令来自动组织项目内部的过滤器结构或磁盘上的文件结构。我想你们中的一些人可能也对这个扩展感兴趣:

https://github.com/reloZid/vc-fileutils

https://github.com/reloZid/vc-fileutils

回答by duDE

I know only this workaround: you create first the folder structure in windows explorer and then drag / drop the files / folder from windows explorer into the solution explorer of Visual Studio. It will add them all as a "filter" to Visual Studio!

我只知道这种解决方法:首先在 Windows 资源管理器中创建文件夹结构,然后将文件/文件夹从 Windows 资源管理器拖放到 Visual Studio 的解决方案资源管理器中。它会将它们全部添加为 Visual Studio 的“过滤器”!