How do I add a child folder to a solution folder?
-
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;
Sol.Create(SolutionPath, SOLUTION_NAME);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.
All Replies
-
Friday, January 07, 2011 12:32 PMModerator
Hello,
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
https://connect.microsoft.com/VisualStudio/feedback/details/635048/notimplementedexception-adding-solution-folder-to-solution-folderUsing 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/- Proposed As Answer by Victor_Chen Wednesday, January 12, 2011 3:15 AM
- Marked As Answer by Victor_Chen Tuesday, January 18, 2011 7:27 AM

