Compartilhar via


Como: Adicionar itens existentes a um projeto

You can add an item you have created to a new or existing project either directly or as a link. You can add nearly any type of existing file from storage to your projects. If you are adding 200 or more files, however, open Windows Explorer and drag them to your project in Solution Explorer for best system performance.

Items that target a different version of the .NET Framework, however, may or may not be used in your project, depending on the particular item and the .NET Framework target version of your project.

Aviso

Before adding any file to your project, determine the trustworthiness of the code outside of Visual Studio. Opening projects or components in certain designers executes code from that item on your local machine and could expose your system to malicious code.

To add an existing item to a project

  1. In Solution Explorer, select a target project.

  2. On the Project menu, select Add Existing Item.

  3. In the Add Existing Item dialog box, locate and select the project item you want to add.

    ObservaçãoObservação

    Some items related to Serviços Web XML and ASP.NET Web applications are located in a virtual directory on the Web server.

  4. Click the Add button to add the item to your project.

You can also add an item as a link rather than directly adding the file to your project. Linked project items in Solution Explorer can be identified by the link indicator in its icon (a small arrow in the lower left corner).

By linking to a file, you can capture ongoing changes to a source file without having to manually update a copy whenever changes are made. However, if the underlying file is deleted, the link will be broken. Se você mover o seu projeto, o vínculo será quebrado, pois o link é relativo.

  1. In Solution Explorer, select the target project.

  2. On the Project menu, select Add Existing Item.

  3. In the Add Existing Item dialog box, locate and select the project item you want to link.

  4. From the Open button drop-down list, select Add As Link.

    ObservaçãoObservação

    If you get the error message, "Cannot add a link to a file that is inside the project tree," you need to create a solution directory for your future solutions by selecting the Create directory for Solution option in the New Project dialog box. For more information, see Como: criar pastas para soluções.

Consulte também

Conceitos

Usando o Solution Explorer

Gerenciamento de itens em projetos