views:

5133

answers:

6

I feel ridiculous for asking this because it seems like it should be so simple, however I have been unable to discover an answer to this question.

I have a free standing set of files not affiliated with any C# project at all that reside in a complicated nested directory structure. I want to add them in that format to a different directory in an ASP.NET web application I am working on; while retaining the same structure. So, I copied the folder into the target location of my project and I tried to “add existing item” only to lose the previous folder hierarchy. Usually I have re-created the directories by hand, copied across on a one-to-one basis, and then added existing items. There are simply too many directories/items in this case.

So how do you add existing directories and files in Visual Studio 2008?

+17  A: 

drag the files / folder from windows explorer into the solution explorer. it will add them all.

Darren Kopp
I'm getting a "The operation could not be completed" error when I try to do this in Visual Studio 2010 Professional. Anyone got a solution?
Matt
http://www.vonsharp.net/CommentView,guid,76230b76-0920-4ac6-8b9a-fcb1d497dcd5.aspx
rolando
This doesn't work for me. It just gives me the icon of an invalid drop target. The show all files below works perfectly though
Cine
A: 

@Darren Kopp That does not add the files & folders to your solution.

I already copied using explorer.

Ian Patrick Hughes
drag the folder. 100% sure this works, because i do it alll the time.
Darren Kopp
Oh, duh. From an explorer window into the IDE! I'll try it right now, but that will probably work. Change your answer to describe that and I'll accept.
Ian Patrick Hughes
+25  A: 

Enable "Show All Files" for the specific project (you might need to hit "Refresh" to see them)**. The folders/files that are not part of your project appear slightly "lighter" in the project tree. Right click the folders/files you want to add and click "Include In Project". It will recursively add folders/files to the project.

** - these buttons are located on the mini Solution Explorer toolbar.

Brannon
also works. didn't think about this.
Darren Kopp
Don't feel bad I used this when a project required reference to an external assembly that was included in source control and I totally didn't think to do it this way. My brain isn't working today.
Ian Patrick Hughes
Good call! Thank you!
mattdell
A real life saver! Thanks!
Peter Perháč
A: 

Brutally simple! Thanks.

Yeah, I felt silly not knowing this one. However, now I use it all of the time.
Ian Patrick Hughes
A: 

I am not sure, but seems I have similar problem that seems not so easily solvable. I would need to have directory structure included in solution and included on solution level, not on project level (structure contains several resources common for all solution projects). There is one kind of item, that resides on solution level (called "solution folder"), but this is only logically created in solution, it does not exist physically on file system. So question is ... how to create physical solution-level directory that can contain some resources usable by all projects in that solution.

Thetam
A: 

Drag and drop concept is working fine for me. thanks alot kopp

mohanmuthusamy