SPDocTemplateCollection 类
代表文档模板的集合。
继承层次结构
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.SPBaseCollection
Microsoft.SharePoint.SPDocTemplateCollection
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Class SPDocTemplateCollection _
Inherits SPBaseCollection
用法
Dim instance As SPDocTemplateCollection
public class SPDocTemplateCollection : SPBaseCollection
示例
下面的代码示例收集到数组中当前网站集的所有网站的所有文档模板,然后循环访问数组元素以显示每个模板的属性。
该示例假定存在的.aspx 页,其中包含一个名为Label1的标签控件。
此示例要求对Microsoft.SharePoint和Microsoft.SharePoint.Utilities命名空间的using指令 (在 Visual Basic 中的Imports )。
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim sites As SPWebCollection = siteCollection.AllWebs
Dim arrDocTemps As New ArrayList()
Dim site As SPWeb
For Each site In sites
Dim docTemps As SPDocTemplateCollection = site.DocTemplates
Dim i As Integer
For i = 0 To docTemps.Count - 1
arrDocTemps.Add(docTemps(i))
Next i
Next site
Dim docTemp As SPDocTemplate
For Each docTemp In arrDocTemps
Label1.Text += SPEncode.HtmlEncode(docTemp.Name) & " :: "
& docTemp.DefaultTemplate & "<BR>"
Next docTemp
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
ArrayList arrDocTemplates = new ArrayList();
foreach (SPWeb oWebsite in collWebsites)
{
SPDocTemplateCollection collDocTemplates = oWebsite.DocTemplates;
for (int intIndex = 0; intIndex < collDocTemplates.Count; intIndex++)
{
arrDocTemplates.Add(collDocTemplates[intIndex]);
}
foreach (SPDocTemplate oDocTemplate in arrDocTemplates)
{
Label1.Text += SPEncode.HtmlEncode(oDocTemplate.Name) +
" -- " + oDocTemplate.DefaultTemplate + "<BR>";
}
oWebsite.Dispose();
}
备注
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。