标签云

微信群

扫码加入我们

WeChat QR Code

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 existingitem” 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?


The fact that this isn't obvious for most people (including me) is a sad testament about Visual Studio.

2019年10月20日13分31秒

Pete Alvin I have many sad testaments about Visual Studio but appreciate it more now that I have spent time with some of the other IDE's out there.

2019年10月20日13分31秒

Visual studio isn't perfect however, I have used just about every IDE available. If is the best. Eclipse isn't even close, Xcode is probably the only one that comes close.

2019年10月21日13分31秒

user1127081: I have to second this. Visual Studio is quite far from perfect, but I have used pretty much every other IDE for pretty much every development and target OS out there and they are all a hell of a lot worse. I also have to agree that Xcode is clearly and by far the best of the rest, but it became so only after it has approved a lot between Xcode 3 and Xcode 4. Eclipse is just a nightmare.

2019年10月20日13分31秒

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

2019年10月20日13分31秒

In VS 2010, after draggin got the folder, choose the option to Show All Files in the project. The files exist in "ghosted" form, right click on the folder and Include in Project. They will then be added

2019年10月21日13分31秒

JohnPtacek: That works in a project, but not in the solution.

2019年10月20日13分31秒

Kill explorer.exe using the task manager, start it as administrator and then you can drag and drop to Visual Studio even if its running as Administrator.

2019年10月20日13分31秒

95% certain that Hossein Shahdoost's comment isn't the best option...

2019年10月20日13分31秒

It seems that this only works for files deeper than your project file, if you keep your project file in a folder on its own, this wont work.

2019年10月20日13分31秒

This only works in individual projects, but not within a solution.

2019年10月20日13分31秒

Duh... that's not where you're supposed to put files.Of course it's not going to find files above your root folder.

2019年10月20日13分31秒

This will only work when you want the folders you add to reside in your project folder. In my case, I want them to be somewhere else (shared between projects). In XCode, dragging a folder structure from any location into project structure preserves the folder sructure instead of flattening it like VS. Looks like VS lacks a feature here.

2019年10月20日13分31秒

tip - ensure the project is selected, not the solution - then you can do show all!

2019年10月20日13分31秒

How is this different than Brannon's answer from 4 years earlier?

2019年10月20日13分31秒

This does not address the original problem which is for a Solution folder. It has also been previously covered.

2019年10月20日13分31秒

ToolmakerSteve: It is different in that it is the same as Gant's solution from... 7 years earlier. stackoverflow.com/questions/392473/…

2019年10月20日13分31秒

Highly recommend this solution as it also helps when conflicting csproj files have been checked in and tfs ignores the conflicts and overwrites

2019年10月20日13分31秒

+1.I found this answer more helpful than the others because it makes it (relatively) clear that Show All Files is an icon, not an entry on the context menu.

2019年10月20日13分31秒

I see the same behavior, VS2010, c++.

2019年10月20日13分31秒

True, also in Visual Studio 2010. It doesn't even add the files without a directory structure for me, just the very first file within that folder structure and not any subfolders.

2019年10月20日13分31秒

Agreed, it still differs. I wonder how a popular and expensive software such as VS can lack such a feature. I consider it rather confusing to have two different yet similar structures in the solution explorer and windows explorer...

2019年10月20日13分31秒

Using 2015 here; still doesn't preserve folder structure. Stunned.

2019年10月20日13分31秒

Using 2015 Update 3, just had success with the approach from Bannon and Tom. All nested folders came in as expected.

2019年10月20日13分31秒

This is for a solution folder, not a project.

2019年10月20日13分31秒

Yep, sometimes hand-editing the *.*proj file will get you where you want to go.

2019年10月20日13分31秒

So you're saying someone could make a plugin to batch-do this? Because I ain't recreating a folder structure with tens of folders by hand in an xml

2019年10月21日13分31秒

Exactly what I was looking for

2019年10月20日13分31秒

This is pretty much what the accepted answer suggests and one of the comments under it.

2019年10月20日13分31秒

Extension didn't work for me on version VS 15.9.13 2017

2019年10月20日13分31秒

This does not maintain directory structure - it just puts everything at the folder where you clicked add.

2019年10月20日13分31秒