This tip examines ways to use the drag and drop features available in the Visual Studio Solution Explorer.
- [Instructor] I don't know about you, but I spend a lot of time in the Solution Explorer window working with files and folders. In this tip, I wanted to look at the drag and drop features available in Solution Explorer. They're similar to the drag and drop features available in the Windows File Explorer. I'm sure you might have used this feature. Stay till the end. I might have a tip or two that you haven't seen. First step is to move a file around inside a project. I have four projects available inside this solution. I work in this CourseLib in these two child folders, Travel and Vehicles.
So I'll move to the Vehicles folder, pick up this Bus.cs file, and drag it and drop it in Travel. Visual Studio Solution Explorer does several things for me. It makes the move, moves that file in a location. It also expanded the Travel folder so I didn't have to do that manually. Again, this is just like what would happen inside File Explorer. I can move it back like that. It's also possible to move multiple files. Hold down the Shift key and select two files, then drag them into the new location.
There are some places in the project you can't drag. Let's open up this one file here. There's this References folder. Let me try dragging it there. Nope, can't drag it there. But I can drag it to the Properties. This looks like, normally this is when you right-click on this and you choose Open, and this opens up a property window. So it looks like this is kind of like a dialog, but actually it is a container that has this file, this AssemblyInfo.cs file. And the information inside this C# file is used to populate some of the information that's in the properties dialog we just saw.
It is possible for me to pick up this file and put it in the Properties folder, although I don't know why you'd want to do that. Nobody would know to look in that location. But I just wanted to point out that this is considered a folder by Visual Studio. Now I'm going to roll back everything. So I'll right-click and choose Undo. That'll reset everything back to the starting position from my Git Repository. Next step is to look at transferring files between projects.
So I've got this ConsoleApp available up here, and I'll take Bus, and I'll drag it into the Console Application. And that makes a copy, so I now have the Bus file here and I also have the Bus file here. If I had wanted to move it, I have to hold down the Shift key. So pick up the file. See, I've got a plus symbol there. That's the symbol inside Windows that means I'm doing a copy operation. Now I hold down the Shift key. The plus symbol goes away.
Now I just have an empty rectangle, and that means I'm doing a move. A lot of these features I've just showed you here, or these actions, I'm sure you've seen or figured out on your own. But let's talk about how we can also work with external files or from an external program. Again, I'll reset everything. And then I will go to this Assets project. Right-click on it and choose Open Folder in File Explorer. And then I'll hold down the Window key and tap the left arrow and select my WeeklyTips.
So now I've got the Visual Studio docked on right side and the File Explorer on the left side. Now what I can do is open a folder here and then drag these files from the Windows Explorer into Solution Explorer. So I'll pick up this robot, drag it over, and it made a copy. Didn't affect the original version. So it's done the right thing. It's updated the CS project file to include this new file. And this works for any file type. So I can go to code files, drag those over.
I can do sound files. And I can do things like text files. Really doesn't matter what kind of file you drop in here. So for the last demonstration I want to talk about how to open solutions. So I will go over here and roll this back again. Then I'll unload the solution, or I'll choose Close Solution, I should say.
Then I will go up to this location, and there's a SLN file here. So one of the techniques you can do, especially if you have multiple monitors on your computer, you might have File Explorer in one monitor and Visual Studio in the other monitor, and you can just grab the solution file and drag it over and drop it in Visual Studio to open that solution. So I'm going to drop it here in the document area. And you see that it opens the solution. And then I'll close it and show you one more.
You can also drop it on the Solution Explorer. So let me show you, I'll go to Team Explorer. I'll try to drop that here, and you'll see I get the do not drop symbol here. And when I get up in this area, and dropped it, and it successfully opened it. You didn't see it, 'cause I had the Team Explorer tab open. So I'm just showing that there's multiple drop locations for solution files in Visual Studio.
Skill Level Intermediate
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.