Udostępnij za pośrednictwem


Items and Common Commands in Solution Explorer

Generally, you can identify how the project manages an item, based on the project template. For example, Visual C++ projects allow the files to reside in any location. Therefore, the items shown in the project are always links to the file; when you manage items in a Visual C++ project, you are actually managing the links. When you are working on a Web project, the projects require that files reside in the project directory so that their relative hyperlinks are readily maintained on the Web server. Therefore, the project maintains the item as if it is the file itself.

Tip

Visual C++ projects, Solution Items, and Miscellaneous Files contain only links. Visual C# Web projects and Visual Basic Web projects contain only physical project items.

For example, you might create a miscellaneous file, decide to add it to a project, and then assume you are adding a new copy of the file and not just a link. If you delete your original miscellaneous file and the project item is actually a link to the original, you can lose your work.

Moving and Copying Items

The target project always determines the outcome of drag or cut and paste operations in Solution Explorer. For more information, see How to: Move Items.

Saving Project Items

The effects of using the Save As command for project items depends on the association of the item to the project.

  • Projects that Manage Links
    Save As creates a new file outside the project hierarchy. The file appears in Miscellaneous Files, if the Show Miscellaneous Files in Solution Explorer option is enabled. See for more information, Documents, Environment, Options Dialog Box.

  • Projects that Manage Files Only
    Save As replaces the current file. The old file is removed and a new one created in its place.

  • Projects that Manage Both Files and Links
    Save As replaces the current file if the new copy is saved to the same directory. Otherwise, Save As replaces the current file as a link.

Removing Project Items

The association that the project maintains with its items determines the methods you can use to remove the item from a project in a given context.

  • Remove
    This command is available in projects that manage both files and links as well as projects that manage links only. When you remove a file from your project the file is disassociated from the project and disappears from Solution Explorer. Removed files are not permanently removed from storage.

    Projects that manage files only do not support the Remove command.

  • Delete
    This command is available in projects that manage both files and links as well as projects that manage files only. Deleted items are permanently removed from file storage and disassociated from the project.

    Projects that manage links only do not support the Delete command.

  • Exclude
    By using this command, you can temporarily remove an item from the project build and subsequently re-introduce it with Show All Files. Not available for all projects.

    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 is not part of the project until you select Include in Project from the Project menu.

See Also

Tasks

How to: Identify How a Project Manages Files

Adding Projects to Source Control

How to: Move Items

How to: Remove, Delete, and Exclude Items

Concepts

Using Solution Explorer

Introduction to Solutions, Projects, and Items