【问题标题】:List of files in a project visual studio 2010项目visual studio 2010中的文件列表
【发布时间】:2012-08-05 18:03:22
【问题描述】:
我正在使用 Visual Studio 2010 SDK 开发一个扩展。我正在尝试获取项目中所有文件的列表,但是目前我无法获取过滤器中的文件列表。我可以看到返回的只是过滤器名称,以及该过滤器中的文件数。
我目前正在使用ProjectItem 接口,特别是FileNamesProperty。但是,在他们的文档中,他们说:
当项目项的 ProjectItems 属性有值,且 ProjectItem 对象表示磁盘上的过滤器文件夹时,FileNames 属性只返回过滤器文件夹的名称。
我可以使用另一种方法来列出过滤器中的文件,还是我解决这个问题的方法有误?
【问题讨论】:
标签:
c#
visual-studio-2010
visual-studio-sdk
【解决方案1】:
所以,我已经在这方面取得了足够的进展,可以继续。我只需要在 Visual C++ 项目中使用这个扩展,所以我可以使用 VCProject Interface 获取项目列表,并使用 VCProject Files 属性从项目中获取文件列表。
像这样的
VCProject prj;
int count = _applicationObject.Solution.Projects.Count;
for(int i = 1; i <= count; i++ )
{
//Start counting at one for some reason
prj = (Microsoft.VisualStudio.VCProjectEngine.VCProject)_applicationObject.Solution.Projects.Item(i).Object;
foreach (VCFile item in prj.Files)
{
//Item is the file, do whatever you want with it here
}
}
我仍然想知道是否有办法为所有项目(不仅仅是 VisualC++)执行此操作。