How to: Remove, Delete, and Exclude Items

The procedure for taking items out of solutions, projects, and folders in Solution Explorer is straightforward. However, the project type determines whether you are deleting the file, keeping the file but removing it as an item in the project, or temporarily excluding it from the project or solution. For more general information about how projects manage files, see Item Management in Projects.

Removing, deleting, and excluding each describe a different degree of disassociation from the project or solution.

If you want to

Then use

Disassociate an item from a solution, project, or folder but not remove its physical file

Remove

Permanently erase files from physical storage as well as the file item in solution, project, or folder

Delete

Temporarily disassociate an item from a project

Exclude

Temporarily disassociate a project from a solution

Unload

Selecting the project or item in Solution Explorer changes the menus and commands available in the development environment. The action performed by certain commands can vary depending on the project template you used to create the project. For more information on the specific project template you have selected, see New Project Dialog Box.

Removing

For projects that manage items as links, such as Visual C++, you can remove an item from your project. The item is removed from Solution Explorer and the item's file is disassociated from the project, but not permanently removed from storage. Projects that manage the items as files, such as Web projects, do not support the Remove command.

To remove an item or project

  1. In Solution Explorer, select the item you want to remove.

  2. On the Edit menu, select Remove.

Deleting

For projects that manage items either as files, such as Web projects, or using a combination of files and links, such as Visual Basic and Visual C#, you can delete an item from your project. The item is removed from Solution Explorer and the item's file is permanently removed from storage. Projects that manage the items as links do not support the Delete command.

To permanently delete an item

  1. In Solution Explorer, select the item you want to delete.

  2. On the Edit menu, select Delete.

Excluding

Using the Exclude command, you can temporarily remove an item from the project. After excluding the file, you can still see it in Solution Explorer by clicking Show All Files. For projects that manage items either as files, or using a combination of files and links, you can exclude an item from your project.

Not all projects allow you to exclude project items from builds. References in Visual C++, other reference-based projects and links to files in Visual Basic and Visual C# projects can be excluded from the project using slightly different methods.

Additionally, you can remove an entire project, and all of its contents from the solution using the Unload command. For more information, see How to: Unload and Reload Projects.

Physical project items in Web and other directory-based projects and physical project items in Visual Basic, Visual C#, and other mixed-model projects can be temporarily removed from a project using the Exclude From Project command.

To temporarily exclude an item that represents a file

  1. In Solution Explorer, select the item you want to exclude.

  2. On the Project menu, select Exclude From Project.

You can include the excluded file in your project by using the Include in Project command.

To include an item that represents a file

  1. In Solution Explorer, select Show All Files. The button for that command looks like this:

    SolutionExplorerShowAllFilesSymbol screenshot

  2. Select the item.

  3. On the Project menu, select Include in Project.

Excluding Items from Deployment Projects

To exclude an item from a deployment project

  1. In Solution Explorer, select the file you want to exclude.

  2. On the Solution Explorer toolbar, select Properties.

  3. In the Properties window, set the Exclude property to True.

See How to: Exclude Items from a Deployment Project for alternative steps.

Note

Adding a file to a project directory in Windows Explorer does not automatically add that file to the project; the file will appear in Solution Explorer in the Show All Files view but it is not part of the project until you select Include in Project from the Project menu.

Unloading

To temporarily unload a project from a solution

  1. In Solution Explorer, select the project you want to unload.

  2. On the Project menu, select Unload Project.

    Note

    Unload Project is unavailable when the solution is not shown in Solution Explorer. To enable this command, select Always show solution in the General, Projects and Solutions, Options Dialog Box.

See Also

Tasks

How to: Unload and Reload Projects

How to: Exclude Files from a Project Output Group

Concepts

Using Solution Explorer

Item Management in Projects