gouldos
gouldos

Reputation: 1153

Get path of a Solution Item file in Visual Studio Add-In

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?

Upvotes: 3

Views: 8264

Answers (2)

Andre Rafalski
Andre Rafalski

Reputation: 1

Try this:

var fullPath = ProjectItem.get_FileNames(1);

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

Upvotes: 0

Stephen
Stephen

Reputation: 3084

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

Upvotes: 3

Related Questions