4

I'm trying to add a folder and some files within it to a Visual Studio 2010 Express VB.NET project. I have read the answers to questions on this subject here and here. They both say "select folder, right click, and then select Add To Project".

But when I right-click in this way, no "Add to Project" option appears. Does anyone know why this is so, and what I can do about it, or alternatively another way of adding a folder to a project?

Community
  • 1
  • 1
Brian Hooper
  • 21,544
  • 24
  • 88
  • 139
  • You probably need to enable the "Show All Files" option, unless they've taken that out because it's too harsh for VB.NET programmers... – Cody Gray - on strike Jan 11 '12 at 09:39
  • 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:53

5 Answers5

3

Yes, this works fine. Click on the "Show All Files". You'll see ghost images of all the files that are not included in your Solution. Right-click on the folder that you want, then click the "Include in Project" It comes right in with no problem and shows up in your Solution Explorer menu.

LDegelman
  • 31
  • 2
1

Click on File.
There you can add a new or an existing project.
Once you've added a new or existing project, you can rightclick and add projects on the solution explorer.
So there is absolutely no need to show hidden fiels etc.

JurgenR
  • 386
  • 1
  • 5
1

I understand your problem because I also use VB.Net 10 Express, and have also used the pukka versions. You do NOT, as you are aware, have the right click add to project facility however there is a way to add an existing form/class/folder etc to a project, but you have to be prepared to dive into the .vbproj file.

Here is an example of one I added to one of my projects. First of all EXIT VB.NET

Now copy the .sln, .suo, .vbproj, .vbproj.user files somewhere else or just zip them up as a backup in case you manage to screw it all up!

Next open the .vbproj file with an editor. You could use notepad or textpad but I use and recommend scite. Anyway whatever you use it must be a plain text editor. Forgive me for stating the obvious but do NOT used Word, WordPad etc.

In the file find the section that starts

<itemgroup> 

You can tell if you have the right one by the fact that the entries say

<Compile Include=

Other groups say reference include or import include and you don't want those. Within that section add the code needed to get your folder and files into the project. Here is a sample:

<Compile Include="SuperPro Extras\FGeophysicalReport.designer.vb">
  <DependentUpon>FGeophysicalReport.vb</DependentUpon>
</Compile>
<Compile Include="SuperPro Extras\FGeophysicalReport.vb">
  <SubType>Form</SubType>
</Compile>

Note that your FOLDER is added at the front of the file names. For each of the vb files you should add the name of the designer file and the name of the code file (as above).

Finally you need to include the resx file. You will find another ItemGroup that comtaines the embedded resource files. The resx file is added into this group in exactly the same way.

<EmbeddedResource Include="SuperPro Extras\FGeophysicalReport.resx">
  <DependentUpon>FGeophysicalReport.vb</DependentUpon>
</EmbeddedResource>

Note the folder\filename on the first line and then the dependency WITHOUT and folder name.

I know this is a LONG time after the question was asked so possibly not usefull to you but I hope it helps someone else. I think I will develop a utility to do this. I have one for assembly/file numbers so this would be a useful addition.

1

I wanted to add a little more comprehension to this as some of the directions were not explicitly clear considering one's level of Visual Studio knowledge. Here's a quickie on how I accomplished this task (using VS2013).

  1. Drag/drop folder you want to include in the Resources folder (i.e. %path%\"Project Name"\"Project Name"\Resources\) For this example, I wanted to add a folder structure named AppData.
  2. In Solution Explorer, on Top Panel, click Show All Files then click Refresh.
  3. Locate your folder (mine: AppData) under Resources then right-click > Include In Project.

Images for guidance:

Sumner Evans
  • 8,951
  • 5
  • 30
  • 47
Jsen Fruge
  • 459
  • 4
  • 6
1

I found this: Visual Studio - Add Existing Folder

Instead what you can do is hit the "Show All Files" tool strip button at the top of the solution explorer, then right click on the folder you want to add and hit "Include In Project". Pretty trivial. Its amazing how long you can use a product and not know about all of its features.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Steve
  • 50,173
  • 4
  • 32
  • 41