我正在尝试获取其下的项目和文件夹列表。我可以使用以下方式获取项目和项目项:
DTE2 dte2;
dte2=(DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");
Projects projects = dte2.Solution.Projects;
然后,我迭代项目项并获取项目的“种类”。但它只显示 GUID。我需要知道该项目是否是文件夹。我怎么做?
Ref:
var item = projects.GetEnumerator();
while (item.MoveNext())
{
var project = item.Current as Project;
for(i=1;i<project.ProjectItems.Count;i++)
{
string itemType = project.ProjectItems.Item(i).Kind;
}
}
EDIT :
目前,我正在使用一种解决方法:
string location = project.ProjectItems.Item(i).get_FileNames(1);
if (location.EndsWith(@"\"))
{
// It is a folder E.g C:\\Abc\\Xyz\\
}
你可以使用EnvDTE.Constants.vsProjectItemKindPhysicalFolder
来比较ProjectItem.Kind
财产反对。
更多常量可以在这里找到:http://msdn.microsoft.com/library/vstudio/envdte.constants
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)