none
refresh solution explorer RRS feed

  • Question

  • I have created an add-in that, among other things, adds a folder and file to the project currently in the solution explorer.  The problem is that this new folder and file do not show up in the solution explorer unless the user presses the refresh icon for the solution (project).

    How can I refresh the file list in the solution explorer programatically in the add-in?  I have tried everything I can think of and searched everywhere.  This would sure help.

    Thanks,
    Nick

    Friday, May 19, 2006 8:41 PM

Answers

  • You can not access the toolbar through the automation model. Do you want to access the toolbar in order to trigger the Refresh button? That is not the way to go in order to run commands. You can do it in two ways:

    1) When the project node is selected the project will enable the View.Refresh command. That will allow you to call DTE.ExecuteCommand("View.Refresh")

    2) Or you can get a handle to the VSProject Object through the Project.Object Property and then call VSProject.Refresh() command

    http://msdn2.microsoft.com/en-us/library/vslangproj.vsproject.refresh.aspx

    /Ole

    Monday, May 22, 2006 5:08 PM

All replies

  • Hello Nick

    Is it a  VS Language project (VB, C# or J#) that you are adding project items to, or is it a custom project type?

    If you use one of .Net languages then you should get the solution refreshed after adding new folders/file items through the automation model (e.g. EnvDTE.ProjectItems.AddFromFile).

    /Ole

    Friday, May 19, 2006 10:42 PM
  • I am not adding folders or files through the automation model but programatically using the system.io namespace.

    I will try this approach.  Just for my edification though, how would I access the toolbar of the solution explorer via the automation model?

    Nick

    Monday, May 22, 2006 2:55 PM
  • You can not access the toolbar through the automation model. Do you want to access the toolbar in order to trigger the Refresh button? That is not the way to go in order to run commands. You can do it in two ways:

    1) When the project node is selected the project will enable the View.Refresh command. That will allow you to call DTE.ExecuteCommand("View.Refresh")

    2) Or you can get a handle to the VSProject Object through the Project.Object Property and then call VSProject.Refresh() command

    http://msdn2.microsoft.com/en-us/library/vslangproj.vsproject.refresh.aspx

    /Ole

    Monday, May 22, 2006 5:08 PM
  • Thank you Ole.  This helps a great deal.

    By the way I had wanted to add a folder to the project that contained the file that was currently in the IDE editor.  I did it this way which works great.

              _applicationObject.ActiveDocument.ProjectItem.ContainingProject.ProjectItems.AddFolder(
                                                                        FolderName,
                                                                        Constants.vsProjectItemKindPhysicalFolder);


    Nick

    Tuesday, May 23, 2006 12:29 PM