6

I want to add the source-code of a tutorial into an existing project, and I want the file to be copied to the project folder from the temporary file on the desktop I downloaded it to. Context clicking on the "Source Files" Folder in the Solution Explorer leads me the Add->Existing Item... menu, and I can then add the source file. However, it is NOT copied into the project folder, but stays in its original location. The project just knows about it, displays it in the Solution Explorer, and considers it part of the project.

This help page on MSDN tells me that in Visual Studio 2010, default behaviour used to consist in copying the file into the project folder, and that one could choose to Add a link instead of physically importing the file into the project directory by choosing "Add Link". However, now I always only get a link, and real physical import into the project folder seems impossible.

I could go through the File Explorer to physically import, but the Solution Explorer doesn't update the new files on the fly, and I would like to do this from within VS.

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

yippy_yay
  • 167
  • 1
  • 1
  • 5
  • 1
    Why, exactly, are you not keen on just copying the file to its proper place in the solution directory yourself? – Michael Petrotta Dec 15 '13 at 21:06
  • Being new to Studio, I don't really know what exact path in the project folders would be canonical (I could figure this out fast, but would keep forgetting.). Leaving the IDE is cumbersome. Then, the Solution explorer only becomes aware of the newly imported files after a project reload.So I would like to keep Visual Studio in the loop. – yippy_yay Dec 15 '13 at 21:34

1 Answers1

11

Copy in the files using Explorer, then in the solution explorer tick the Show All files option in the button bar of the solution explorer (you might need to select a Project first).

Show All Files

You can now right-click any files not part of the projects and choose Include in Project.

Include in Project

Or use the Add Existing File option.

The reason files are not added automatically to your solution when pasted into the folder using Explorer is because you might not want to have them added.

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

Open in Explorer

(though it might be added by the Productivity Power Tools).

Plus, you can Drag&Drop files directly from explorer to the Visual Studio (when they're both running in the same elevation level if you have User Account Control enabled). To fix the UAC issues, you can either run Explorer as administrator too or install the VSCommands extension.

And you can Copy&Paste a file or set of files into the solution explorer by right-clicking a project or project folder and picking Paste on the context menu.

Community
  • 1
  • 1
jessehouwing
  • 106,458
  • 22
  • 256
  • 341