Thursday, January 06, 2011 8:56 PM
We are using DevStudio 2008 and I have a stand-alone app that builds a cut-down version of our project. At one point during the process, I add a solution folder to the solution to hold the ini entries. I want to create sub folders underneath that folder. Here is my sample code:
Solution OrigSol = System.Activator.CreateInstance(Type.GetTypeFromProgID("VisualStudio.Solution")) as EnvDTE.Solution;
Solution2 Sol = OrigSol as Solution2;
Project IniFolder = Sol.AddSolutionFolder("Inis");
string DirName = Path.GetFileNameWithoutExtension(Dir);
ProjectItem IniSubFolder = IniFolder.ProjectItems.AddFolder(DirName,EnvDTE.Constants.vsProjectItemKindVirtualFolder);
The call to AddFolder fails saying not implemented. I've also tried using vsProjectItemKindPhysicalFolder and vsProjectITemKindMisc. All 3 fail.
How do I add a child folder to Inis? Thanks.
Friday, January 07, 2011 12:32 PMModerator
I have reproduced the problem. FWIW, I have opened a bug report at Microsoft Connect to get an official answer from Microsoft, because a NotImplementedException is not a bug, but there should be a way to create child solution folders using the automation model (EnvDTE).
NotImplementedException adding solution folder to solution folder
Using the VS SDK it seems that the method to use is IVSProject3.AddItem , but it is not clear how to do it.
MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/