Share via

Item Management in Projects

Visual Studio offers a wide variety of project templates to give you the items you need to create your application. This variety means that the commands and capabilities available in Solution Explorer varies depending on the project template you select and how that project manages items. Although you can control where you want files saved and stored, the project template determines whether or not the location is significant in building and managing the files.

Two Possible Associations with Files

The items in Solution Explorer often represent a particular file and that file can be associated with a project in one of two ways. Either the item represents a link to the file or represents the file itself. Links are similar to but not the same as a shortcut in Windows Explorer.

While working within a single project, you might not notice the behavioral differences between items that represent links and items that represent the file itself. However, while performing tasks between projects, the Solution Items folder, and the Miscellaneous Files folder, you might encounter unexpected results.

You are most likely to notice the differences when working simultaneously with Visual C++ and Web projects. To better understand the differences, consider the scenarios that illustrate how files are associated with a project.

Some projects do not require the files to reside within the project's directory structure and the project manages only links to the file. Links serve as proxies for physical files on disk. Such projects do not require the full range of file management tasks.

Project Model Solution Explorer Storage 2

For example, when you manage only the link to a file you can remove the link, but removing it does not delete the file from storage. Such associations allow you to create and maintain a single file that can be used in several projects.

Items such as those in Visual C++ projects and the Solution Items folder are links. In projects that use items as links, you can store the files anywhere on a disk and still include them in a build. You can add items that are links to files in other projects.

Linking to files that were created outside a project allows you to share files between projects so you can capture ongoing changes to a file without updating a copy whenever changes are made. However, you can link to a file that could be accidentally deleted, such as one belonging to another user. If you do not want to share the file through a link, you can create a copy of it and then add the copy to your project. The item in the project might still be a link, but it links to its own version of the file.

Projects that Manage Files

Some projects, such as Web projects, require that all of its files reside within or under the same physical directory. This directory is called the project directory and for each item that appears in the project in Solution Explorer, a physical file exists in the project directory. This association allows both the directory structure and the project file to identify which files are available to and managed by the project. Such a project also uses all items in the build.

Project Model Solution Explorer Storage 1

Some projects, such as Visual Basic and Visual C#, manage the files using a combination of both associations. Some items that appear in the project's folder in Solution Explorer are like links to the file. Other items are managed as the file itself. These projects typically indicate items that are links with a small arrow in the icon.

Project Model Solution Explorer Storage3

When you are working in a project that allows both types of associations, you might notice that files for items can be stored anywhere. The project file tracks files contained in the project, information for source code control, and other metadata.

See Also


How to: Identify How a Project Manages Files

Adding Projects to Source Control


Using Solution Explorer

Introduction to Solutions, Projects, and Items

Items and Common Commands in Solution Explorer