我目前正在尝试构建一个类似于VSNewFile的加载项。所以它只是一个简单的扩展,它提供了一种更快的方式来创建新文件。VSNewFile 的问题在于它不适用于 C++ 项目,我需要它。
这是我的问题:
我无法检索所选目录的绝对路径。我发现的所有示例都是这样的:
(string)((ProjectItem)parent).Properties.Item("FullPath").Value;
虽然这是在 C# 项目中工作,但它不在 C++ 项目中。在 C++ 项目中,selectedItem.Project
当我选择一个目录时。重要提示:我不是在谈论过滤器!我的意思是真正的目录。
欢迎任何帮助。我已经搜索了几个小时没有成功。
谢谢selectedItem.ProjectItem
null
问问题
754 次
1 回答
0
也许这会帮助遇到同样问题的其他人: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;
}
于 2010-09-20T01:26:10.373 回答