gpt4 book ai didi

c# - 项目 visual studio 2010 中的文件列表

转载 作者:行者123 更新时间:2023-11-30 15:38:05 24 4
gpt4 key购买 nike

我正在使用 Visual Studio 2010 SDK 开发扩展。我正在尝试获取项目中所有文件的列表,但目前我无法获取过滤器中的文件列表。我能看到返回的只是过滤器名称,以及该过滤器内的文件数。

我目前正在使用 ProjectItem接口(interface),特别是 FileNames属性(property)。但是,在他们的文档中,他们说:

When the project item's ProjectItems property has a value, and the ProjectItem object represents a filter folder on the disk, then the FileNames property returns only the name of the filter folder.

我是否可以使用另一种方法来列出过滤器中的文件,或者我是否以错误的方式解决了这个问题?

最佳答案

所以,我在这方面取得了足够的进展,可以继续。我只需要在 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++)执行此操作。

关于c# - 项目 visual studio 2010 中的文件列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11818781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com