Freigeben über


Solution3.AddSolutionFolder-Methode

Fügt einen Projektmappenordner einer ProjectItems-Auflistung hinzu.

Namespace:  EnvDTE90
Assembly:  EnvDTE90 (in EnvDTE90.dll)

Syntax

'Declaration
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

Parameter

  • Name
    Typ: String

    Der Name des Projektmappenordners.

Rückgabewert

Typ: Project
Ein Project-Objekt.

Hinweise

AddSolutionFolder gibt ein Project-Objekt zurück, für das Sie eine Schnittstellenabfrage erstellen oder das Sie in ein SolutionFolder-Objekt umwandeln können.

Beispiele

Informationen zum Ausführen des Add-In-Codes finden Sie unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

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 Solution3 =  _
        CType(_applicationObject.Solution, Solution3)
        Dim solnName As String = _
        System.IO.Path.GetFileNameWithoutExtension(soln.FullName)
        MsgBox("Adding a new folder to " & solnName)
        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
    {
        Solution3 soln = (Solution3)_applicationObject.Solution;
        string solnName =
          System.IO.Path.GetFileNameWithoutExtension(soln.FullName);
        MessageBox.Show("Adding a folder to the solution " + solnName);
        soln.AddSolutionFolder("MyNewFolder");
    }
    catch(SystemException ex)
    {
        MessageBox.Show("ERROR: " + ex);
    }
}

.NET Framework-Sicherheit

Siehe auch

Referenz

Solution3 Schnittstelle

EnvDTE90-Namespace

Weitere Ressourcen

How to: Organize a Solution Using Solution Folders

Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell