Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying source files into a Visual Studio project

I've created a new Visual Studio C++ project and I'd like to import copies of a number of C and header files into the project. That is, the files are currently in a folder on my desktop and I'd like to import them such that copies are placed in the newly created project folder.

How would I do this? I've tried using File | New | Project from Existing Code but that just keeps the files in their existing location. I've even tried a simple Ctrl-C and Ctrl-V and again that imported the files but they stayed in the same place on disk.

like image 334
Simon Morgan Avatar asked Oct 23 '12 13:10

Simon Morgan


People also ask

How do I add a source file to Visual Studio?

First, select DevTools > Settings > Experiments > Open source files in Visual Studio Code, and then re-start DevTools.

How do I create a project from an existing source in Visual Studio?

On the File menu, select New > Project From Existing Code. Specify your project location, the directory for your source files, and the kinds of files the wizard imports into the new project. Choose Next to continue. Specifies the directory path of the new project.

How do I copy a file from one project to another in Visual Studio?

Click the arrow button to the right of the file and select Move or Copy file from the dropdown menu. When you choose Copy this file from the move or copy dropdown, you will then be able to select which project to copy it to. You can make a copy of the file in the existing project or in another project.


2 Answers

Copy the files to the new location in Windows Explorer, then start Visual Studio and add them as existing items to the project.

like image 61
SvenS Avatar answered Oct 06 '22 00:10

SvenS


I think the better solution would be to create a new (empty) project and add your h and cpp files per "Add -> Existing item" in the context menu of "Headers" and "Sources"

like image 37
AquilaRapax Avatar answered Oct 06 '22 01:10

AquilaRapax