CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2009
    Posts
    73

    Question 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!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    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)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: How to identify a certain file as belong to a certain solution?

    You should explain what exactly you are trying to do.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  4. #4
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: How to identify a certain file as belong to a certain solution?

    Quote Originally Posted by cilu View Post
    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

  5. #5
    Join Date
    Apr 2009
    Posts
    73

    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
  •  





Click Here to Expand Forum to Full Width

Featured