3

Is there a way to create a blank solution, or some type of file-based project solution within Visual Studio so that I can point to a root folder, and have all of the sub-folders and files in that root, show up in my solution explorer? I realize I can create a blank solution and then add the individual items manually by add > existing item, however, this does not keep the folder structure intact, and, well, it would take forever if I have a lot of folders/files.

GEOCHET
  • 21,119
  • 15
  • 74
  • 98
EvilSyn
  • 2,412
  • 7
  • 24
  • 22
  • adding files to a solution or project? – StingyJack Oct 24 '08 at 15:25
  • Basically, what I'd like, is to just have 'windows explorer' as my solution explorer. That way I can go through the tree of folders, select a file to edit. I don't want to create a web app or other app, then show all files, and include them in the project. I don't need a project, just need to edit. – EvilSyn Oct 24 '08 at 15:31
  • Well if you are just wanting to edit files in VS, why not browse in IE and then right click on files and open them with VS? – wprl Oct 24 '08 at 19:20
  • possible duplicate of [How to "Add Existing Item" an entire directory structure in Visual Studio?](http://stackoverflow.com/questions/57776/how-to-add-existing-item-an-entire-directory-structure-in-visual-studio) – nawfal Aug 07 '13 at 08:54

2 Answers2

4

You can also create the blank solution and then click the second-from-the-right icon at the top of the solution explorer (it looks like three files with one "cut out"). Once you click that button to show the files in the solution directory that are not in a project, you can select all the files (with shift-click) and then right-click on your selection and select "Include In Project."

Also note you can select multiple files in the "Add Existing..." file window with shift- or control-click.

wprl
  • 24,489
  • 11
  • 55
  • 70
  • My blank solution for VS.NET 2008 only has two icons on top of the solution explorer - Properties, and Add New Solution Folder. Also, shift/ctrl clicking multiple files gives me the issue where it just brings the files into explorer at the root.. not in their nice folder structures. – EvilSyn Oct 24 '08 at 15:13
  • I am pretty sure the 'show all files' icon is only visible when you have an actual project and not a blank solution.. – EvilSyn Oct 24 '08 at 15:14
2

You have to create a Visual Studio Project inside your solution to be able to add files with keeping their folder structure. The files to be added must reside below the project's main folder.

I suggest adding a "C# Empty Project" (Solution Explorer: Solution > Add > New Project ... > Visual C# > Windows > Empty Project). After that you can proceed as described by SoloBold to show the files in the project folder. Right click on the topmost folder of your source files an select "Include In Project" and the whole folder structure including all files will be added. This may take some time depending on the number of files / subfolders.

See also: Answer to similar question, with screenshot

Community
  • 1
  • 1
oleschri
  • 2,012
  • 11
  • 21
  • I did this using Empty Project... but you will run into problems during advanced build servers as it will try to compile your empty project or complain it doesn't have an entry point. My solution was based on this, except I use right-click solution -> "Add -> Existing Website" . This way any folder structure will do and you can add or remove folders at will – Tim Davis Jun 15 '20 at 05:42