Partager via


ProjectItems.AddFromTemplate(String, String) Method

Definition

Creates a new project item from an existing item template file and adds it to the project.

public:
 EnvDTE::ProjectItem ^ AddFromTemplate(System::String ^ FileName, System::String ^ Name);
public:
 EnvDTE::ProjectItem ^ AddFromTemplate(Platform::String ^ FileName, Platform::String ^ Name);
EnvDTE::ProjectItem AddFromTemplate(std::wstring const & FileName, std::wstring const & Name);
[System.Runtime.InteropServices.DispId(203)]
public EnvDTE.ProjectItem AddFromTemplate (string FileName, string Name);
[<System.Runtime.InteropServices.DispId(203)>]
abstract member AddFromTemplate : string * string -> EnvDTE.ProjectItem
Public Function AddFromTemplate (FileName As String, Name As String) As ProjectItem

Parameters

FileName
String

Required. The full path and file name of the template project file.

Name
String

Required. The file name to use for the new project item.

Returns

A null reference.

Attributes

Remarks

When you call AddFromTemplate, there is no need to explicitly create a new solution (such as with DTE.Solution.Create), because AddFromTemplate automatically creates a solution.

Note

The ProjectItems.AddFromTemplate method always returns null. In order to retrieve the added ProjectItem, you can interate through the ProjectItems collection, or use the ProjectItemEvents.ItemAdded event.

Applies to