Visual Studio & C++: Use filters as directories
Solution 1
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.
Solution 2
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:
https://github.com/reloZid/vc-fileutils
Solution 3
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!
Related videos on Youtube
bytecode77
„What I cannot create, I do not understand.“ - Richard Feynman bytecode77.com
Updated on July 10, 2020Comments
-
bytecode77 almost 4 years
I Use Visual Studio 2012 Professional and 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)
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?
-
bytecode77 about 11 yearsThat's pretty much the problem, everything is unfiltered when switching back to normal view. Also this way cpp and h files are both displayed in the same filter because they are in the same directory.
-
jt234 about 11 years@DevilsChild I understand your problem. As far as I know, what you are describing can not be done. I hope the option will be added in an update or next release.
-
bytecode77 about 11 yearsI hope so, too. For now I'm satisfied with the "Show All Files" option.
-
Gabe Halsmer over 7 yearserrr...that did not work for me in vs2015. The hierarchy of folders becomes flat in solution explorer. Bascially I get the list of files, without any filters.
-
Laurie Stearn about 6 years^ Ditto for VS2017.
-
Tomáš Zato about 5 yearsYou cannot use "Add class" and other context menus when in folder view.
-
Deepak Kiran about 4 years@DevilsChild Your comment helps quiet a lot, because when you state it's not possible, then I don't have to search anythiing more. Will need to wait for future releases.
-
Louka about 3 yearssplendid extension. Was looking for that for so long!
-
User One over 2 yearsThanks, this solve the problem!