也许这会帮助其他有同样问题的人:
http://social.msdn.microsoft.com/forums/en-US/vsx/thread/bd738463-ba24-4880-beea-f3ec110d981e
// Subscribe to the SVsShellMonitorSelection service somewhere:
public void mySetupMethod()
{
IVsMonitorSelection monitorSelection =
(IVsMonitorSelection)Package.GetGlobalService(
typeof(SVsShellMonitorSelection));
monitorSelection.AdviseSelectionEvents(this, out cookie);
}
// This class (as used in AdviseSelection) must implement the IVsSelectionEvents interface
// To get the folder path use the following
public int OnSelectionChanged(IVsHierarchy pHierOld, uint itemidOld,
IVsMultiItemSelect pMISOld, ISelectionContainer pSCOld,
IVsHierarchy pHierNew, uint itemidNew, IVsMultiItemSelect pMISNew, ISelectionContainer pSCNew)
{
string fullPath;
// Get the full path
pHierNew.GetCanonicalName(itemidNew, out fullPath);
// Do something with the path...
return VSConstants.S_OK;
}