Aracılığıyla paylaş


VSProject.TemplatePath Özellik

Visual Basic veya C# proje öğesi şablonları içeren dizinin tam yolunu alır.Salt okunur.

Ad alanı:  VSLangProj
Derleme:  VSLangProj (VSLangProj.dll içinde)

Sözdizimi

'Bildirim
ReadOnly Property TemplatePath As String
string TemplatePath { get; }
property String^ TemplatePath {
    String^ get ();
}
abstract TemplatePath : string with get
function get TemplatePath () : String

Özellik Değeri

Tür: String
Şablon yolu temsil eden bir string değeri döndürür.

Notlar

Bu özellik, projenin bir Visual Basic projesi veya bir C# projesi olmasına bağlı olarak uygun şablon dizin yolunu döndürür.

Formları ve modülleri gibi özel proje öğeleri için şablon yolu kopyalanabilir.Bu öğeleri daha sonra yeni öğeler için şablonlar olarak hizmet.AddFromTemplate Yöntemi, ProjectItems nesne proje dizininde şablonun bir kopyasını oluşturur ve belirtilen projeye proje öğesi ekler.Bir örnek aşağıda verilmiştir.

Örnekler

[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

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

VSProject Arabirim

VSLangProj Ad Alanı