|
-
May 14th, 2009, 04:42 PM
#1
How to identify a certain file as belong to a certain solution?
Hi,
I'm writing a VS2008 Add-In in C#.
When a solution is opened, I have the Solution object (from the DTE object).
Given a certain path to a file, I'm trying to distinguish whether or not this file belong to the solution or not.
I tried to solve this by iterating all the projects in the solution (by "solution.Project.GetEnumerator()"), and in each project iterate all the project items (by project.ProjectItems.GetEnumerator()"), and I am getting most of the files that belong to the solution, but for some reason, there are files which are not in the project items I'm iterating.
For example, if I have a form class, then the file "Form.cs" is one of the project items, but files like "Form.Designer.cs" and "Form.resx" are not found in the project items collection. Also files under the property directory, e.g. "AssemblyInfo.cs" are not found (only the "Properties" is found as a project item).
Can someone please:
1. Tell me whether is a better way to distinguish whether a certain file belong to a solution or not ?
2. Tell me why the files specified above are not listed in the project items collections ?
Thanks!
-
May 14th, 2009, 06:54 PM
#2
Re: How to identify a certain file as belong to a certain solution?
1) What are you using? If you know that a file exists of each type, and you have the folder, you could just browse the folder with a filter
2) Not sure
#3> Why? (mine for you)
-
May 15th, 2009, 07:50 AM
#3
Re: How to identify a certain file as belong to a certain solution?
You should explain what exactly you are trying to do.
-
May 15th, 2009, 09:16 AM
#4
Re: How to identify a certain file as belong to a certain solution?
 Originally Posted by cilu
You should explain what exactly you are trying to do.
hmm, didn't he say that he's writing an add-in for visual studio and that this add-in should handle the file added event when a file has been added to a solution?
win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming
remeber to give feedback  you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation
private lessons are not an option so please don't ask for help in private, I won't replay
if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know
-
May 21st, 2009, 01:57 PM
#5
Re: How to identify a certain file as belong to a certain solution?
Hi,
Sorry for the late reply.
I got the answers to my two questions here they are:
1) dte.Solution.FindProjectItem()
2) The specified items above appears, but not in the first level. They are childs of project items in the project. Need to iterate the project items, and for each project item which have childs, iterate them as well, recursively.
Regards
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|