ryf9059
ryf9059

Reputation: 739

Move source file location outside Visual Studio 2012

I want to group some source file into a folder for better organization, but visual studio will not recognize them once they are moved, the file path cannot be changed from VS inside (at least I don't know if there is a way to do so). Is there a better way other than excluding the file and re-adding them again? It's very tedious painful to do so once you have a lot of files. Any suggestions?

For example in my solution I have stdafx.h, stdafx.cpp and resource.h directly under the root directory while in VS it displayed under a header folder. What I wanted to do is to create a actual Header folder under root directory and move them into that folder.

Edit: If I do so by excluding and re-including files during build time I get this error:

cannot overwrite information formed during creation of the precompiled header in object file stdafx.obj

This stdafx.h file is automatically there along with the creation of a win32 application project, I heard that I should create precompiled header file under setting. So I set stdafx.cpp to Yc (create precompiled header) and set all the other .cpp file to Yu (use precompiled header). But while building error message saying fatal error C1083: Cannot open include file: 'stdafx.h'. But the fact is that stdafx.h is right under the Header folder in the root directory and is included from that folder and it could be opened in VS, but there is still read lines under that include statement and hence the error.

Upvotes: 0

Views: 2236

Answers (1)

Arne Mertz
Arne Mertz

Reputation: 24626

You can manually edit the *vcxproj and *sln files, they are plain xml files. Look up the entries of your moved files in those xml files and correct the paths to match the directories where you put them. This might be a bit tedious but only applies if you restructure your folders manually like you did.

Upvotes: 1

Related Questions