Compartir a través de


Solution2.AddSolutionFolder (Método)

Agrega una carpeta de soluciones a una colección ProjectItems.

Espacio de nombres:  EnvDTE80
Ensamblado:  EnvDTE80 (en EnvDTE80.dll)

Sintaxis

'Declaración
Function AddSolutionFolder ( _
    Name As String _
) As Project
Project AddSolutionFolder(
    string Name
)
Project^ AddSolutionFolder(
    String^ Name
)
abstract AddSolutionFolder : 
        Name:string -> Project 
function AddSolutionFolder(
    Name : String
) : Project

Parámetros

Valor devuelto

Tipo: EnvDTE.Project
Un objeto Project.

Ejemplos

Para obtener información sobre cómo ejecutar este código de complemento, vea Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización

En el siguiente ejemplo se muestra cómo agregar una nueva carpeta a una solución abierta.

Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    _applicationObject = CType(application, DTE2)
    _addInInstance = CType(addInInst, AddIn)
    SolnFolderExample(_applicationObject)
End Sub
Sub SolnFolderExample(ByVal dte As DTE2)
    ' This add-in adds a new folder to an existing solution.
    Try
        Dim soln As Solution2 =  _
        CType(_applicationObject.Solution, Solution2)
        Dim solnName As String = _
        System.IO.Path.GetFileNameWithoutExtension(soln.FullName)
        MsgBox("Adding a new folder to " & solnName)
        Dim Proj As Project
        proj = soln.AddSolutionFolder("MynewFolder")
    Catch ex As System.Exception
        MsgBox(ex.ToString)
    End Try
End Sub
using System.Windows.Forms;
public void OnConnection(object application,
 Extensibility.ext_ConnectMode connectMode, object addInInst,
 ref System.Array custom)
{
    _applicationObject = (DTE2)application;
    _addInInstance = (AddIn)addInInst;
    // Pass the applicationObject member variable to the code example.
    AddSolnFolderExample((DTE2)_applicationObject);
}

public void AddSolnFolderExample(DTE2 dte)
{
    // This add-in adds a folder to an existing solution. 
    // Open a solution in 
    // Visual Studio before running this example.
    try
    {
        Solution2 soln = (Solution2)_applicationObject.Solution;
        string solnName =
 System.IO.Path.GetFileNameWithoutExtension(soln.FullName);
        MessageBox.Show("Adding a folder to the solution " + solnName);
        Project proj = soln.AddSolutionFolder("MyNewFolder");
    }
    catch(SystemException ex)
    {
        MessageBox.Show("ERROR: " + ex);
    }
}

Seguridad de .NET Framework

Vea también

Referencia

Solution2 Interfaz

EnvDTE80 (Espacio de nombres)

Otros recursos

Cómo: Organizar una solución utilizando carpetas de soluciones