ProjectItems.AddFolder 方法

在**“解决方案资源管理器”**中创建新文件夹。

命名空间:  EnvDTE
程序集:  EnvDTE(在 EnvDTE.dll 中)

语法

声明
Function AddFolder ( _
    Name As String, _
    Kind As String _
) As ProjectItem
ProjectItem AddFolder(
    string Name,
    string Kind
)
ProjectItem^ AddFolder(
    String^ Name, 
    String^ Kind
)
abstract AddFolder : 
        Name:string * 
        Kind:string -> ProjectItem 
function AddFolder(
    Name : String, 
    Kind : String
) : ProjectItem

参数

  • Name
    类型:System.String
    必选。“解决方案资源管理器” 中文件夹节点的名称。
  • Kind
    类型:System.String
    可选。要添加的文件夹的类型。

返回值

类型:EnvDTE.ProjectItem
一个 ProjectItem 对象。

备注

AddFolder 向项目和 ProjectItems 集合中添加文件夹,并返回新创建的 ProjectItem 对象。它的 ProjectItems 集合是空的。某些类型的项目不支持添加某些种类的文件夹(如 vsProjectItemKindVirtualFolder)。

示例

此示例仅适用于 Visual Studio .NET 2003。有关更多信息,请参见 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

.NET Framework 安全性

请参见

参考

ProjectItems 接口

EnvDTE 命名空间

其他资源

控制项目和解决方案

如何:编译和运行自动化对象模型代码示例