In particular, I was wondering if it was possible for Visual Studio to treat source files in different directories as all in the same directory. I first saw this after purchasing the Introversion Software Humble Bundle which gave people access to their source code for their previous games from Subversion. I noticed with one of their games that it was split into physical folders for different parts (like "\world", "\lib", ect.), but in Visual Studio the files were put into filters with the same names as the physical folder and all of the files were treated as if they were in the base directory. I also noticed that they included files in the VS project that weren't even in the base project folder. This is what I mean:

Project and Folder Layout

Things like the \data folder are included with the folders from \source, even though they are in different directories and levels.

What I also want to know is how to go about including folders and files from different locations and treat them all like they are all in the same place. But most of all, I would like to figure out how they made all source files act like they were all in the base folder, instead of the separate physical folder that they are, as shown by the #includes in the files:

enter image description here

Image Here

As you can see, the app.h/.cpp files are in the "\app" folder, but the includes are able to reference things from "\lib" without including "..\lib" to go up a folder, effectively treating all of the source files like they originate in the base folder.

TL;DR: How does one include multiple folders from different places as filters, and how do you treat all source files like they originate from the same place.

Any help is greatly appreciated, as this will help me organize my project better. Thanks.


The structure of what VS calls "filters" (just folders in the project tree) is entirely independent of the structure of directories on disk. There's no connection between them. You can choose to make the filters match the directories, if you like, but VS doesn't do that automatically or anything.

When you add files to your project, you can select them from any directory. They go into the root filter by default, regardless of their location on disk. VS will internally maintain a relative path from the project file to each source file (you can see these if you open up the .vcxproj). Then you can create filters as you like and drag different files into them. It doesn't move the files on disk, just reorganizes the project.

  • \$\begingroup\$ Thanks for the prompt answer. But does this explain how to source files in the different physical folders are able to #include other files without "..\" to go up a directory? \$\endgroup\$
    – sm81095
    Sep 12 '13 at 2:19
  • 2
    \$\begingroup\$ That's because visual studio allows you to set paths called include directories. If there is an include directory pointing to where that file is you can still #include it without having to do any directory switching. \$\endgroup\$ Sep 12 '13 at 2:43
  • \$\begingroup\$ Ah yes. I never even thought to use the include directories like that. Thanks to both of you for the answers! \$\endgroup\$
    – sm81095
    Sep 12 '13 at 2:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.