Get ProjectItem path without using item.Document.FullName
Asked Answered
E

4

9

I have a visual studio add-in project where I must iterate through the current project's items, utilizing the absolute (or relative) path to those files.

The item.Document.FullName works, but only for files that are currently opened.

Is there any other way to access this information in the DTE object?

Embow answered 19/7, 2011 at 21:14 Comment(0)
X
26

Is this what you're looking for?

myProjectItem.Properties.Item("FullPath").Value
Ximenez answered 13/9, 2011 at 14:49 Comment(2)
And this link has some more specific info about what is contained in the properties list for a ProjectItem: msdn.microsoft.com/en-us/library/ms228957(v=vs.90).aspxGarganey
Is there any list of properties?Prismatic
M
4

Even I was looking for a solution to get the project name based on the document or file Name. I found it by using the DTE object. Initialized the DTE object like the code shown below.

EnvDTE80.DTE2 objDTE = this.GetService(typeof(SDTE)) as EnvDTE80.DTE2;

Then I used following code, to get the name of the project.

var projectItem = objDTE.Solution.FindProjectItem(document);
var projectUniqueName = projectItem.ContainingProject.UniqueName;
Monoacid answered 10/8, 2016 at 14:42 Comment(0)
E
0

We found that, unless we wanted to parse the XML project files ourselves, you have to first load any unloaded projects.

We record the list and unload them again afterwards so the only issue is the time it takes to load them.

Eleonoreleonora answered 9/8, 2011 at 10:50 Comment(0)
L
0

ProjectItem.FileNames is a collection that represents the full paths of the associated files

For example if you have webform item called "MyWebForm" you can get from ProjectItem.FileNames the full path of the MyWebForm.ascx file an the full path name of the MyWebForm.ascx.cs (CodeBehind) file

Lenoir answered 9/8, 2011 at 13:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.