Import an existing source file in Visual Studio 2012

I want to add the source code of the tutorial to an existing project, and I want the file to be copied to the project folder from the temporary file on the desktop on which I downloaded it. The context, clicking on the "Source Files" folder in Solution Explorer, brings me to the Add-> Existing Item ... menu, and I can add the source file. However, it is NOT copied to the project folder, but remains in its original location. The project just knows about it, displays it in the solution explorer and considers it as part of the project.

This MSDN help page tells me that in Visual Studio 2010, the default behavior is to copy the file to the project folder and that you could select Add Link instead of physically importing the file into the project directory by selecting "Add Link". However, now I always get the link, and real physical import into the project folder seems impossible.

I can go through File Explorer for physical import, but Solution Explorer does not update new files on the fly, and I would like to do this from VS.

Is there any way? Is this a bug in VS 2012?

+3
visual-studio-2012
source share
1 answer

Copy the files in Explorer, then in the Solution Explorer check the Show All files option on the button bar in the solution explorer (maybe you need to select a project first).

Show all files

Now you can right-click any files that are not part of the projects and select Include in Project .

Include in Project

Or use the Add Existing File option.

Reason files are not automatically added to your decision when pasted into a folder using Explorer, because you may not want to add them.

A subtle little trick is to use the "Open In explorer" option:

Open in explorer

(although it may be added Performance Power Tools ).

In addition, you can drag and drop files directly from Explorer in Visual Studio ( when they both work at the same height level, if you have User Account Control enabled ). To fix UAC problems, you can either run Explorer as an administrator or install the VSCommands extension .

And you can copy and paste the file or set of files into the solution explorer by right-clicking the project or project folder and selecting Paste in the context menu.

+10
source share

All Articles