Partager via


SolutionFolder Interface

Definition

Solution folders are project containers that allow developers to better organize large applications.

public interface class SolutionFolder
public interface class SolutionFolder
__interface SolutionFolder
[System.Runtime.InteropServices.Guid("F8F69788-267C-4408-8967-74F26108C438")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface SolutionFolder
[System.Runtime.InteropServices.Guid("F8F69788-267C-4408-8967-74F26108C438")]
public interface SolutionFolder
[<System.Runtime.InteropServices.Guid("F8F69788-267C-4408-8967-74F26108C438")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type SolutionFolder = interface
[<System.Runtime.InteropServices.Guid("F8F69788-267C-4408-8967-74F26108C438")>]
type SolutionFolder = interface
Public Interface SolutionFolder
Attributes

Examples

This example creates a new solution folder and adds a project to it from an existing file. Before running this example, create a "Projects" folder off your main drive ("C:" in this example), and create a Visual C# class library project, named "ClassLibrary1" in that folder. You must also open a project in the Visual Studio integrated development environment (IDE) before running this example.

Imports EnvDTE  
Imports EnvDTE80  
Sub solnFolderAddFromFileExample(ByVal dte As DTE2)  
    ' Before running this example, create a "Projects" folder  
    ' off your main drive (C: in this example), and create a C#   
    ' class library project, named ClassLibrary1 in that folder.  
    Dim soln As Solution2 = CType(_applicationObject.Solution _  
    , Solution2)  
    Dim prj As Project  
    Dim SF As SolutionFolder  
    Try  
        Dim prjPath As String = _  
        "C:\Projects\ClassLibrary1\ClassLibrary1\ClassLibrary1.csproj"  
        ' Open a project in the Visual Studio IDE before running   
        ' this example.  
        ' Add a solution folder.  
        prj = soln.AddSolutionFolder("A new soln folder")  
        SF = CType(prj.Object, SolutionFolder)  
        ' Add a project to the new solution folder.  
        SF.AddFromFile(prjPath)  
        MsgBox("Added a new solution folder that contains a _  
        C# project named ClassLibrary1.")  
    Catch ex As System.Exception  
        MsgBox(ex.ToString)  
    End Try  
End Sub  
using EnvDTE;  
using EnvDTE80;  
using System.Windows.Forms;  
public void solnFolderAddFromFileExample(DTE2 dte)  
{  
    // Before running this example, create a "Projects" folder  
    // off your main drive (C: in this example), and create a C#   
    // class library project, named ClassLibrary1 in that folder.  
    Solution2 soln = (Solution2)_applicationObject.Solution;  
    Project prj;  
    SolutionFolder SF;  
    try  
    {  
        String prjPath =  
 "C:\\Projects\\ClassLibrary1\\ClassLibrary1\\ClassLibrary1.csproj";  
        // Open a project in the Visual Studio IDE before running   
        // this example.  
        // Add a solution folder.  
        prj = soln.AddSolutionFolder("A new soln folder");  
        SF = (SolutionFolder)prj.Object;  
        // Add a project to the new solution folder.  
        SF.AddFromFile(prjPath);  
    MessageBox.Show("Added a new solution folder that contains a   
C# project named ClassLibrary1.");  
    }  
    catch(SystemException ex)  
    {  
        MessageBox.Show(ex.ToString());  
    }  
}  

Remarks

In Visual Studio 2005, solutions can contain solution folders in addition to project folders. Solution folders are project containers that allow developers to better organize large applications.

The solution's Projects property returns a collection of Project objects. Each individual Project has a Kind property which can be set to vsProjectKindSolutionFolder. To get to the SolutionFolder interface, call Project.Object, and then cast the object returned to a SolutionFolder type.

Properties

DTE

Gets the top-level extensibility object.

Hidden

Sets or gets the hidden attribute of the solution.

Parent

Gets the immediate parent object of a Find object.

Methods

AddFromFile(String)

Adds an existing project to the solution folder.

AddFromTemplate(String, String, String)

Adds a new project to the solution folder based on a project template.

AddSolutionFolder(String)

Adds a solution folder to a ProjectItems collection.

Applies to