我想獲取項目和文件夾下的列表。我能夠獲得使用項目和項目項:如何獲取項目下的文件夾?
DTE2 dte2;
dte2=(DTE2)System.Runtime.InteropServices.Marshal.
GetActiveObject("VisualStudio.DTE.10.0");
Projects projects = dte2.Solution.Projects;
然後,我通過項目的項目迭代並獲得該項目的「種」。但它只顯示GUID。我需要知道該項目是否爲文件夾。我怎麼做?
編號:
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;
}
}
編輯:
目前,我使用的一種變通方法:
string location = project.ProjectItems.Item(i).get_FileNames(1);
if (location.EndsWith(@"\"))
{
// It is a folder E.g C:\\Abc\\Xyz\\
}
我剛剛注意到,我所提供的解決方案是可從常規文件夾有不同的GUID SolutionFolders。但是,我希望常規文件夾共享相同的GUID,如果與SolutionFolder GUID不同,則可以使用您的解決方法來獲取常量並將其存儲爲常量。 – thudbutt