Adding and Removing Files from Projects
Home Page (Projects) | Overviews | How Do I... Topics | NMAKE Reference
When you add a file to a project, you add the file to all configurations for that project. For instance, if you have a project named MyProject, with Debug and Release configurations, adding a file adds it to both those project configurations.
If you add files from directories on a different drive than the project, Visual C++ uses absolute paths in the filenames for those files in the project's .dsp file. Because of the absolute paths, it is difficult to share the project (.dsp) file. Other developers in your group may have other drive names.
To support sharing files outside the project directory, you can use the Persist As field in the source file's property page. In the Persist As field, put in a replacement path for the file that will be persisted ("preserved") in the project file.
For example:
Add a file, c:\basefiles\mybase.cpp, to your project, where your project is located at c:\myproject\project1.
Use the Persist As field in either of two ways:
In the Persist As field, change the string "c:\basefiles\mybase.cpp" to "..\..\basefiles\mybase.cpp."
This requires all users of the project to maintain the same directory structure that you use for the project.
-or-
- Define an environmental variable, such as "BASEFILES," that contains "c:\basefiles" on the user's machine, and change the string in the Persist As field from "c:\basefiles\mybase.cpp" to "$(BASEFILES)\mybase.cpp."
Note: The NMAKE utility requires that you use upper case for the environment variable names.
What do you want to do?
Add files to a project
Move or copy files from one project to another
Remove files from a project
To add files to a project
Open the project to which you want to add files.
On the Project menu, click Add To Project, and then click Files.
In the Files of type box, specify the type of files to add.
Select one or more files.
Click OK.
Note You can also use the shortcut menu from FileView to add files more quickly.
To move or copy files from one workspace to another
From the FileView pane, select the files that you want to move or copy.
On the Edit menu, click Cut if you want to move the files, or Copy if you want to copy the files.
Close the current project workspace.
Open the destination project workspace.
Select the project to receive the files.
On the Edit menu, click Paste.
To remove files from a project
From the FileView pane, select the files that you want to remove.
On the Edit menu, click Delete.