10

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?

Mrchief
  • 75,126
  • 20
  • 142
  • 189
Jason
  • 211
  • 5
  • 10

4 Answers4

26

Is this what you're looking for?

myProjectItem.Properties.Item("FullPath").Value
IndieGameDev
  • 2,905
  • 3
  • 16
  • 29
puremic
  • 261
  • 2
  • 3
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;
Twenty
  • 5,234
  • 4
  • 32
  • 67
shekhar Kumar
  • 409
  • 4
  • 13
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.

iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
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

BALKANGraph
  • 2,031
  • 1
  • 15
  • 16