VSProject.TemplatePath Propriété

Définition

Obtient le chemin d'accès complet au répertoire contenant les modèles d'élément du projet pour Visual Basic ou C#. Lecture seule.

public:
 property System::String ^ TemplatePath { System::String ^ get(); };
public:
 property Platform::String ^ TemplatePath { Platform::String ^ get(); };
[System.Runtime.InteropServices.DispId(8)]
public string TemplatePath { [System.Runtime.InteropServices.DispId(8)] get; }
[<System.Runtime.InteropServices.DispId(8)>]
[<get: System.Runtime.InteropServices.DispId(8)>]
member this.TemplatePath : string
Public ReadOnly Property TemplatePath As String

Valeur de propriété

String

Retourne une valeur de chaîne représentant le chemin d'accès au modèle.

Attributs

Exemples

[Visual Basic]

' Macro Editor  
' Uses the template path to add a copy of the   
' CompanyTemplate form to the project.  
Imports VSLangProj  
Sub TemplatePathExample()  
   ' This example assumes that the first project in the solution is   
   ' either a Visual Basic or C# project.  
   Dim aVSProject As VSProject = _  
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)  

   ' Use the path to create a new project item.  
   Dim aProject As Project = DTE.Solution.Projects.Item(1)  
   Dim thePath As String = aVSProject.TemplatePath  
   Dim formName As String = InputBox("Name of new form with extension:")  
   Dim newItem As ProjectItem  
   newItem = aProject.ProjectItems.AddFromTemplate(thePath & _  
      "\CompanyTemplate.vb", formName)  
End Sub  

Remarques

Cette propriété retourne le chemin d’accès au répertoire de modèles approprié, selon que le projet est un projet Visual Basic ou un projet C#.

Les éléments de projet personnalisés, tels que les formulaires et les modules, peuvent être copiés dans le chemin d’accès du modèle. Ces éléments peuvent ensuite servir de modèles pour de nouveaux éléments. La AddFromTemplate méthode de l' ProjectItems objet crée une copie du modèle dans le répertoire du projet et ajoute l’élément de projet au projet spécifié. Un exemple suit.

S’applique à