次の方法で共有


ProjectItems.AddFolder(String, String) Method

Definition

Creates a new folder in Solution Explorer.

EnvDTE::ProjectItem AddFolder(std::wstring const & Name, std::wstring const & Kind = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}");
[System.Runtime.InteropServices.DispId(206)]
public EnvDTE.ProjectItem AddFolder (string Name, string Kind = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}");
[<System.Runtime.InteropServices.DispId(206)>]
abstract member AddFolder : string * string -> EnvDTE.ProjectItem
Public Function AddFolder (Name As String, Optional Kind As String = "{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}") As ProjectItem

Parameters

Name
String

Required. The name of the folder node in Solution Explorer.

Kind
String

Optional. The type of folder to add.

Returns

A ProjectItem object.

Attributes

Examples

This example works only in Visual Studio .NET 2003. For more information, see Migrating Code that Creates Projects by Using Templates.

Sub AddFolderExample()  
   ' This function creates a solution and adds a Visual Basic Console  
   ' project to it.   
   Dim soln As Solution  
   Dim proj As Project  
   Dim projitems As ProjectItems  

   ' Create a reference to the solution.  
   soln = DTE.Solution  

   ' Create a new solution.  
   soln.Create("c:\temp2", "MyNewSolution")  

   ' Create a new Visual Basic Console application project.  
   ' Adjust the save path as needed.  
   proj = soln.AddFromTemplate("C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\ConsoleApplication\Templates\1033\ConsoleApplication.vbproj", "c:\temp2", "My New Project", True)  
   projitems = proj.ProjectItems  

   ' Add a folder.  
   projitems.AddFolder("A New Folder")  
End Sub  

Remarks

AddFolder adds a folder to the project and the ProjectItems collection and returns the newly created ProjectItem object. Its ProjectItems collection is empty. Some types of projects do not support adding certain kinds of folders (for example, vsProjectItemKindVirtualFolder).

Applies to