Udostępnij za pośrednictwem


Solution4.AddSolutionFolder(String) Method

Definition

Adds a solution folder to a ProjectItems collection.

public:
 EnvDTE::Project ^ AddSolutionFolder(System::String ^ Name);
public:
 EnvDTE::Project ^ AddSolutionFolder(Platform::String ^ Name);
EnvDTE::Project AddSolutionFolder(std::wstring const & Name);
[System.Runtime.InteropServices.DispId(102)]
public EnvDTE.Project AddSolutionFolder (string Name);
[<System.Runtime.InteropServices.DispId(102)>]
abstract member AddSolutionFolder : string -> EnvDTE.Project
Public Function AddSolutionFolder (Name As String) As Project

Parameters

Name
String

The name of the solution folder.

Returns

A Project object.

Implements

Attributes

Examples

Sub SolnFolderExample(ByVal dte As DTE2)  
    ' Add a new folder to an existing solution.  
    Try  
        Dim soln As Solution4 =  _  
        CType(_applicationObject.Solution, Solution4)  
        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 AddSolnFolderExample(DTE2 dte)  
{  
    // Add a folder to an existing solution.   
    // Open a solution in Visual Studio before running this example.  
    try  
    {  
        Solution4 soln = (Solution4)_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);  
    }  
}  

Remarks

AddSolutionFolder returns a Project object that you can cast or query interface (QI) to a SolutionFolder object.

Applies to