Import existing source file structure into Visual Studio

Leros

Lifer
Jul 11, 2004
21,867
7
81
I have an existing C++ project that is nicely organized by directories. Most IDEs use this directory structure in their project browser, but Visual Studio users what it calls filters, which don't seem to relate to directory structure.

When I import the project into Visual Studio, it just puts all the files into one flat filter (all cpp files in "Source Files" and all h files "Header Files").

I can manually add filters to mimic the directory structure, but this takes time and is quite tedious. Is there a way to do this automatically?
 

TheRyuu

Diamond Member
Dec 3, 2005
5,479
14
81
Create empty project -> Nuke the 3 created folders.

Throw your nicely laid out source tree in the project folder.
Click "Show all files."

Right click folder(s) => Add to project.

At least that's what google said.
 
Last edited:

Leros

Lifer
Jul 11, 2004
21,867
7
81
Create empty project -> Nuke the 3 created folders.

Throw your nicely laid out source tree in the project folder.
Click "Show all files."

Right click folder(s) => Add to project.

At least that's what google said.

That's what I did. It added them as a flat structure.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
If you goto the top of the Solution Explorer there's a button that says 'Show All Files'.

Toggling that gets rid of the Source/Headers filters and shows you the directory structure.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
If you goto the top of the Solution Explorer there's a button that says 'Show All Files'.

Toggling that gets rid of the Source/Headers filters and shows you the directory structure.

Nope. Still all flat.
 

LokutusofBorg

Golden Member
Mar 20, 2001
1,065
0
76
If you use the Solution Explorer to add folders then they should come in exactly as they are on disk... You have to use the "Include in project" option.

If you use the File menu, or you right-click the project and choose Add existing... or anything of the sort, then you won't get the folder structure on disk.