locked
Add SolutionFolder with editable label. RRS feed

  • Question

  • Hi,

    I create new solution folder using this code: 

    EnvDTE80.Solution2 solution = item.Object as EnvDTE80.Solution2;
    
    if (solution != null)
    {
    	EnvDTE.Project folder = solution.AddSolutionFolder("NewFolder");
    
    	return null;
    }

    But if i want to create two folders I have some error. How can i create SolutionFolder and rename it.

    Thanks.

    Wednesday, November 5, 2014 10:31 AM

Answers

  • Hi Andrei,

    The VS Isolated Shell project doesn't provide "Project.AddNewSolutionFolder" command, I think a workaround for you is to give the user a input window to get the new added solution folder name, just before you call SolutionFolder.AddSolutionFolder method.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Caillen Friday, November 7, 2014 2:53 AM
    • Marked as answer by Caillen Monday, November 17, 2014 2:28 AM
    Friday, November 7, 2014 2:52 AM

All replies

  • Why don't you use a different name for the second folder?

    Which error are you getting?

    Can you post the code that creates the second folder?


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Wednesday, November 5, 2014 12:34 PM
  • don't you use a different name for the second folder because I want specify folder name when it created: when I click "New Solution Folder" created new solution folder with editable label.  
    Wednesday, November 5, 2014 1:15 PM
  • The Solution2.AddSolutionFolder method is not intended to prompt the user for a folder name, it expects the folder name as parameter.

    If you want to simulate the Add>New Folder menu click (which does prompt for a folder name) try DTE.ExecuteCommand("Project.NewFolder")


    * My new blog about VSX: http://www.visualstudioextensibility.com * Twitter: https://twitter.com/VSExtensibility * MZ-Tools productivity extension for Visual Studio: http://www.mztools.com.

    Wednesday, November 5, 2014 5:02 PM
  • But this command ("Project.NewFolder") do not create SolutionFolder.
    Thursday, November 6, 2014 8:11 AM
  • I select other SolutionFolder and execute this code:

    EnvDTE.UIHierarchyItem selItem = DTE_GetSelUIHierarchy(dte);            
    
    // No selected items.
    if (selItem == null)
    	return null;
    
    selItem.DTE.ExecuteCommand("Project.NewFolder");
    But it does not work.

    Thursday, November 6, 2014 8:15 AM
  • Also I don't found command "Project.AddNewSolutionFolder" in my Shell Isolated application. But in Visual Studio this command exist.
    Thursday, November 6, 2014 8:24 AM
  • Hi Andrei,

    The VS Isolated Shell project doesn't provide "Project.AddNewSolutionFolder" command, I think a workaround for you is to give the user a input window to get the new added solution folder name, just before you call SolutionFolder.AddSolutionFolder method.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Caillen Friday, November 7, 2014 2:53 AM
    • Marked as answer by Caillen Monday, November 17, 2014 2:28 AM
    Friday, November 7, 2014 2:52 AM