获取 Visual Studio 加载项中解决方案项文件的路径

发布于 2024-09-27 14:42:54 字数 333 浏览 0 评论 0原文

我正在迭代解决方案及其项目和项目,并且需要检索磁盘上项目的路径。

我可以从 Project.FullName 检索项目文件名,并可以使用 ProjectItem.Properites.Item("FullPath") 获取项目项路径。

但是,对于解决方案“解决方案项目”文件夹中的项目,项目属性成员为空,并且没有我可以看到的其他属性可以帮助我检索该项目的路径。

尽管默认情况下它在添加时将位于与解决方案相同的目录中,但我不能依赖此假设,因为它可以从另一个位置移动或添加为预先存在的项目。

是否有其他方法或我缺少的东西来查找该文件的位置?

I'm iterating through a solution and its projects and items and need to retrieve the path to the items on disk.

I can retrieve the project file name from Project.FullName and can get a project items path using ProjectItem.Properites.Item("FullPath").

However, for an item in the solutions 'Solution Items' folder, the items Properties member is null and has no other properties which I can see could help me retrieve the path to the item.

Although by default it will be located in the same directory as the solution when it is added I can't rely on this assumption as it could be moved or added as a pre-existing item from another location.

Is there another way or something I'm missing to find the location of this file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南城追梦 2024-10-04 14:42:54

看一下这里,特别是“FileNames”属性: http://msdn .microsoft.com/en-us/library/envdte.projectitem.aspx

Take a look here, particuarly the "FileNames" property: http://msdn.microsoft.com/en-us/library/envdte.projectitem.aspx

与风相奔跑 2024-10-04 14:42:54

试试这个:

var fullPath = ProjectItem.get_FileNames(1);

我不知道为什么他们不从 0 开始

Try this:

var fullPath = ProjectItem.get_FileNames(1);

I don't know why they don't start from 0

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文