Visual Studio Development Bookmark and Share   
 index > Visual Studio Extensibility > How to add files to a new project sub folder
 

How to add files to a new project sub folder

I am developing an add-in.

So far it is working, but a small improvement is proving elusive.

The add-in basically creates special class/struct files from SQL server table definitions, this is working well.

But right now it adds the files to the project root, and they appear and work fine.

But I want organize this a bit better and put these files into a project sub folder "Data Defintions".

Obvioulsy it that exists already I want to use it, if not then I want to create it and use it.

Well I create the folder OK, but the files still appear within the project root itself and not the new sub folder.

I create the folder using:

sub_folder = active_project.ProjectItems.AddFolder("Data Definitions",Constants.vsProjectItemKindPhysicalFolder );
and I (try to) add the files with

sub_folder.ProjectItems.AddFromFile(file_dir + @"\" + names[X]);  // Give the full path of file's contents.
After all this, I see a physical folder on disk, a folder icon in the project itself but the files are still written to the project root folder on disk and the project root folder in the IDE.

So the folder is there, but empty both the physical one and the IDE one.

Can anyone shed light on this behaviour?

Thx

Cap'n



Captain Kernel  Tuesday, October 13, 2009 1:04 PM
Ahoy Captain,

the AddFromTemplate method should do the trick. Please have a look at this thread .

Kind regards
Sebastian
Sebastian Dyck  Tuesday, October 13, 2009 3:24 PM
Ahoy Captain,

the AddFromTemplate method should do the trick. Please have a look at this thread .

Kind regards
Sebastian
Sebastian Dyck  Tuesday, October 13, 2009 3:24 PM
Ahoy Captain,

the AddFromTemplate method should do the trick. Please have a look at this thread .

Kind regards
Sebastian

Thanks Sebastian, that worked a dream, much appreciated.

Regards

Cap'n

Captain Kernel  Tuesday, October 13, 2009 6:07 PM

You can use google to search for other answers

Custom Search

More Threads

• Assign NUM 5 to Macro?
• MPF, get project references in LanguageService
• How to: Create Elements in Code?
• PE Verifier error: missing dependency on EnvDTE v 7.x
• (VS08) InvalidComObjectException on exist after subscribing to CommandBar event.
• Unable to cast object of type
• VS 2008: How to Load WPF Custom controls programatically to ToolBox?
• Fatal error CTC2114 when compiling wizard-generated DSLs
• ProjectNode.UnloadProject()
• Problems installing our product after using the new Sept 2006 SDK