Import Existing Items into a Project (.NET)

Importing allows you to add an existing item to your project that might already exist in another project. You can import code or class modules and forms. Files with the VB extension can only be imported in a VB.NET project and CS files in a C# project. Class diagrams are stored as CD files and can be imported in either project type.

When you import an item, a copy of the file or a link to the file you are importing is added to the project. When a copy of the item is created, the original file is left unaltered in its original place. Linked files provide access to the original file, which is great for reusing common code that might be shared between multiple projects.

If you import an item with the same name as an existing item, you are prompted to replace the existing item in the project with the one being imported.

The imported component is added to your project and appears in the Solution Explorer. To edit the properties of the item, select the item in the Solution Explorer and change its properties in the Properties window.

Procedures

    To import an existing item into a project

  1. In Microsoft Visual Studio, Solution Explorer, right-click the project to which you want to add an existing item and click Add Existing Item.
  2. In the Add Existing Item - <Project> dialog box, browse to and select the file that contains the item you want to add.
  3. Click Add to create a copy of the selected file, or click the down arrow to the right of the Add button and click Add As Link to create a link to the file instead of creating a copy of the file.