标签云

微信群

扫码加入我们

WeChat QR Code

The issue is simple really. Instead of creating folders in Visual Studio, I create a directory structure for my project on the file system. How do I include all the folders and files in a project, keeping the structure?If I "Add Existing File" on a folder named Services and navigate to a file in the directory structure .. Services > AccountManagement > CreateAccount.cs, it appears in Visual Studio like so: Services > CreateAccount.cs. I do not want this.I have an entire directory structure worked out already, as I am mimicking our client developers using the same structure for organization. How do I add all the folders and files to the project in Visual Studio? Or do I have to do what most Microsoft users do and "put up with it" and recreate each and every folder through Visual Studio?


possible duplicate of How to "Add Existing Item" an entire directory structure in Visual Studio?

2019年09月19日36分22秒

Is there a way to do this with a directory (tree) outside of the project directory?

2019年09月19日36分22秒

Is there a way to do this for a folder that is NOT a subdirectory of where your project is? i.e.: Have E:\ProjectX\project.vcproj include the folder E:\Common*.cs ??

2019年09月19日36分22秒

Almost works.I can see the directory tree, and add multiple files, but it won't let me add a whole directory including sub-trees.

2019年09月18日36分22秒

The problem is that it ONLY WORKS if you copy the directory tree in your Visual project through the Windows explorer. How can you do if you just want to reference some folders and files contained in an other project on your computer ?

2019年09月18日36分22秒

Only way I know of to do this outside the project is using a symbolic link... see my answer: stackoverflow.com/a/26537736/835561

2019年09月19日36分22秒

This does not work in my installation of VS 2010 on Vista Ultimate 64 bit.

2019年09月19日36分22秒

No, does not work in my VS 2010 installation on Windows 7 either.

2019年09月18日36分22秒

Confirming this doesn't work in VS 2010 (non-Administrator mode) too

2019年09月18日36分22秒

I don't think you guys are doing it right. VS 2010 does support folder drag n drop. I do it all the time to include my tool-kits. You have to make sure that you drop into the project tree. The solution panel and the solution node itself will not receive the drop. The OS is irrelevant here, but for doubters, I use Windows 7 64 bit.

2019年09月18日36分22秒

"Solution Items" are different than adding items to a project. Solution Items are a special folder within the VS solution.

2019年09月18日36分22秒

I found this helpful because I could then include a single tag for "copy always on build", rather than needing to annotate every individual file (as was the case in the accepted answer)

2019年09月18日36分22秒

IMO one of the most useful answers here.

2019年09月18日36分22秒

Where is that added? How do you get to an XML view in VS?

2019年09月19日36分22秒

MatthewDean stackoverflow.com/a/5129214/3195477

2019年09月19日36分22秒

this is the best solution when you want add large hierarchy folder while Visual Studio is not responding & get hang.

2019年09月19日36分22秒

This worked for me but drag and drop didn't work in VS14 and Windows 10 pro.

2019年09月19日36分22秒

drag and drop may not work unless you are running VS as administrator

2019年09月18日36分22秒

It doesn't work! symbolic links are not recognized as folders

2019年09月18日36分22秒

Anoop: I've added steps to show how I use this method. Please give it a try.

2019年09月18日36分22秒

Its working! I was trying to create a shortcut by right-clicking the folder, instead of using the command prompt and thus it did not work. Following the steps described above fixed the issue. Thanks

2019年09月18日36分22秒

Note: mklink will not work on a FAT file system.It is for NTFS.

2019年09月18日36分22秒

Source control will wreak havoc with Symbolic links. Git needs admin privileges or just checks in the file.

2019年09月19日36分22秒

This should be the answer!

2019年09月19日36分22秒

The question is on how to add an existing folder to the solution, not just to view folders.

2019年09月18日36分22秒

This is a really good option to see the actual structure, to open a folder in file explorer etc - but unfortunately you can't add an existing folder treefrom the folder view. That is only possible in the solution view, as Gant has described it.

2019年09月19日36分22秒