How do I “Add Existing Item” an entire directory structure in Visual Studio?

前端 未结 18 1283
眼角桃花
眼角桃花 2020-11-28 00:18

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 for

相关标签:
18条回答
  • 2020-11-28 00:51

    In Windows 7 you could do the following:

    Right click on your project and select "Add->Existing Item". In the dialog which appears, browse to the root of the directory you want to add. In the upper right corner you have a search box. Type *.cs or *.cpp, whatever the type of files you want to add. After the search finishes, select all files, click Add and wait for a while...

    0 讨论(0)
  • 2020-11-28 00:53

    A neat trick I discovered is that if you go to "Add existing...", you can drag the folder from the open dialog to your solution.

    I have my Visual Studio to open in Admin Mode automatically, so this was a good workaround for me as I didn't want to have to undo that just to get this to work.

    0 讨论(0)
  • 2020-11-28 00:54

    Drag the files / folders from Windows Explorer into the Solution Explorer. It will add them all. Note this doesn't work if Visual Studio is in Administrator Mode, because Windows Explorer is a User Mode process.

    0 讨论(0)
  • 2020-11-28 00:54

    The cleanest way that I've found to do this is to create a new Class Library project in the target folder, and redirect all of its build output elsewhere. It still leaves a .csproj file sitting in that folder, but it does let you see it in Visual Studio and pick which files to include in your project.

    0 讨论(0)
  • 2020-11-28 00:55

    Below is the icon for the 'Show All Files', just for easy reference.

    0 讨论(0)
  • 2020-11-28 00:58

    You need to put your directory structure in your project directory. And then click "Show All Files" icon in the top of Solution Explorer toolbox. After that, the added directory will be shown up. You will then need to select this directory, right click, and choose "Include in Project."

    0 讨论(0)
提交回复
热议问题