Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 How to: Add Existing Items to a Pro...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Studio
How to: Add Existing Items to a Project

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.

Caution noteCaution:

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.

    NoteNote:

    Some items related to XML Web Services 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.

To create a link to an existing item

  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.

    NoteNote:

    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 How to: Create Directories for Solutions.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Add As Link Fails      DanThMan   |   Edit   |   Show History
I have a folder in the root directory of my project called Subfolder.

I have a file located in the root directory of my project called style.css.

If I try to put a link to style.css inside Subfolder, it doesn't work. I don't get an error, but the link doesn't show up.

This is a bug: It should either give me an error if this feature is not supported or it should work.
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker