user1934212 user1934212 -4 years ago 67
C++ Question

preserving original folder structure when creating a project from original c++ code in Visual Studio

When I create a project from existing c++ code with the folder structure

- src
- subfolder1
file1.h
file1.cpp
.
.
.
- subfolder2
file2.h
file2.cpp
.
.
.
.
.


The original file structure is lost in the solution explorer and all the source files are under "Source Files" while the header files are under "Header Files".

How can I create a project from existing code such that the original folder structure is reflected in the solution explorer?

Answer Source

The way files are shown in solution explorer by default are a projection and not the actual structure. If you want to view the files as they are laid out on the file system you should turn on "Show All files" option on the solution explorer, the drawback being that this is a per project setting so you'll have to toggle it for all projects

If you want, you could also organize the files in the solution with filters to match the layout on the disk (by hand, or if this is something you want to automate by writing a program to update the *.vcxproj.filter xml file). The drawback in this case would be that you'll have to remember to maintain this if when you add new files.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download