Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving files from one Visual Studio solution to another

What I usually do is create a new file in the solution where I want to use it (same name), copy & paste the contents of a class from the source solution to the target, fix the namespace & imports as needed.

The only other way I know to do it is open the source file in the target solution and then just save a copy into that folder, which can get confusing with two files open with the same name in one solution.

Does anyone have an easier way to do this?

like image 814
Berryl Avatar asked Feb 03 '10 03:02

Berryl


People also ask

How do I move files from one project to another in Visual Studio?

Copying files from one project to another is out in the open (for the most part). As one option, we can right-click on the source file and choose "Copy" and then right-click on the destination project and choose "Paste".

How do I move a solution file in Visual Studio?

Right click Solution (. sln) in Source Control Explorer and select Move as mentioned above. Set the path of the new folder and select OK.

How do I move a solution to another folder in Visual Studio?

Open solution explorer in Visual Studio and select the solution. and choose the new location.

How do I add an existing project to another solution in Visual Studio?

To add an existing project to a solutionOn the File menu, point to Add, and click Existing Project. In the Add Existing Project dialog box, locate the project you want to add, select the project file, and then click Open. The project is added to the selected solution.


2 Answers

You can just copy and paste the files themselves.

When you have your solution open, look at the top of the solution explorer and you'll see an icon that looks like a page with a page outline behind it and a yellow page (not a very intuitive icon). This is the "show all files" button. Click that and you'll see all the files in your currently selected project (it is project-specific). Highlight any files that you want to include, right-click, and select "Include in Project."

enter image description here

like image 181
Jay Avatar answered Oct 07 '22 10:10

Jay


You could just copy the file with Explorer. Or better yet, start refactoring your projects so that you'll create assemblies that are usable by multiple client projects.

like image 28
Hans Passant Avatar answered Oct 07 '22 09:10

Hans Passant