How to get the template title for a SharePoint site


using
System;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
namespace
SiteTemplates
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:1111/sites/SPSiteDataQuery/"))
{
using (SPWeb web = site.RootWeb)
{
SPWebTemplateCollection templateCollection = site.GetWebTemplates(site.RootWeb.RegionalSettings.LocaleId);

string templateName = web.WebTemplate + "#" + web.Configuration;
foreach (SPWebTemplate webTemplate in templateCollection)
{
if (webTemplate.Name.Equals(templateName))
{
Console.WriteLine("\"{0}\",\"{1}\"",webTemplate.Title, templateName);
}
}
Console.ReadLine();
}
}
}
}
}
Ebook Download
View all
Learn
View all