Visual Studio Tip #8: Adding existing files with Show All Files
Sometimes instead of adding a new file to your project, you need to reuse an existing file. That might be code, but often it is some sort of content like a bitmap or an xml document.
I’ve seen new users copy that item into their project directory and then look at their project in Visual Studio and say “Um, where’s my file?”
For most project types the folder is not the project. The project file (*.csproj, *.vbproj, etc) contains a list of all the files in the project which usually just happen to live in the same folder structure. Visual Studio manages the project file so you need to tell Visual Studio to add that file to the project.
The formal way to add a file that already exists is the Add Existing Item menu.
But often I’ll use the Show All Files feature instead.
There is a button in the Solution Explorer called “Show All Files”. (If the button isn't there, make sure you have the project selected and not the solution.)
Click that button and Visual Studio will that will show all the files in the project folder and not just those that are included in the project. Files and folders that are not currently part of the project will have their icons shown with dotted outlines
Then you can just right-click the file you want to include, and select Include in Project. That will promote the file into your project.
You can then disable “Show All Files” to get back to the regular view.
This post is part of a series of Visual Studio tips. The first post in the series contains the whole list.
(next tip: Edit directly in the Diff tool)