Visual Studio Developer Center >
Visual Studio Forums
>
Visual Studio Extensibility
>
How to refresh the solution explorer tree?
How to refresh the solution explorer tree?
- I have been developing a package in VS2008 for C++ projects where files and folders are removed and added to the project every so often. I have noticed recently that folders that are removed from the project do not automatically get removed from the "Solution Explorer" tree. After, I click the "refresh" button the folder will disappear.
I would like the "Solution Explorer" to automatically refresh upon a directory removal just like the "refresh" button does.
I have tried to perform a refresh by activating the "Solution Explorer" window, selecting the project item, and then executing a refresh, but this throws an exception stating the command is not available.
Dte.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Activate(); UIHierarchy solutionExplorer = Dte2.ToolWindows.SolutionExplorer; UIHierarchyItem solutionItem = solutionExplorer.UIHierarchyItems.Item(1); UIHierarchyItem projectItem = solutionItem.UIHierarchyItems.Item(1); projectItem.Select(vsUISelectionType.vsUISelectionTypeSelect); DTE.ExecuteCommand("View.Refresh", String.Empty);
Thanks
Jeremy
Answers
- Hi Jeremy,
Your code runs well on my side, have you checked is current selected item correct? or you could try to Sleep() a while after projectItem.Select() to let the Solution Explorer refresh the commands.
Sincerely,
Wesley
Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byWesley YaoMSFT, ModeratorThursday, November 05, 2009 2:46 AM
All Replies
- Hi Jeremy,
Your code runs well on my side, have you checked is current selected item correct? or you could try to Sleep() a while after projectItem.Select() to let the Solution Explorer refresh the commands.
Sincerely,
Wesley
Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.- Marked As Answer byWesley YaoMSFT, ModeratorThursday, November 05, 2009 2:46 AM
Hello,
How are you? Is your problem resolved? May I know whether the above suggestions helped you?
Thanks,
Wesley
Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.


