다음을 통해 공유


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.

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.)

show-all-files-button

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

show-all-files-enabled

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.

Include-in-project-menu

You can then disable “Show All Files” to get back to the regular view.

project includes existing file

 

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)

Comments

  • Anonymous
    March 31, 2016
    I really need to do this, but when I right click on a ghosted folder or file in solution explorer, I do not get the option "Include In Project".Any ideas?
    • Anonymous
      April 05, 2016
      No, sorry. I haven't ever seen that happen before. I haven't personally tried this in Community edition but I know it should work in the other editions. Fortunately though, you can always fall back on the "Add Existing Item" menu option in the project menu.
  • Anonymous
    July 31, 2017
    Thanks!!!
  • Anonymous
    August 28, 2018
    No, there isnt a button. How to without the button? How to expose said button on the default website without the button? People don't search the internet if there was a button. D- advice.
    • Anonymous
      September 07, 2018
      There should also be a menu option Project->Show All Files