List template文件放在Site Actions – Galleries - List templates中。
1.上传.stp文件
As SPSite)
, Application.StartupPath)
Try
Then
, System.IO.SearchOption.TopDirectoryOnly)
TryCast(_site.GetCatalog(SPListTemplateType.ListTemplateCatalog), SPDocumentLibrary)
Then
In templates
9:
New System.IO.FileInfo(template)
New SPQuery()
, fileInfo.Name)
As SPListItemCollection = listTemplates.GetItems(query)
14:
Integer(existingTemplates.Count - 1) {}
To existingTemplates.Count - 1
17: Ids(i) = existingTemplates(i).ID
Next
To Ids.Length - 1
20: listTemplates.Items.DeleteItemById(Ids(j))
Next
22:
Byte() = System.IO.File.ReadAllBytes(template)
24: listTemplates.RootFolder.Files.Add(fileInfo.Name, stp)
Next
If
If
As Exception
29:
Try
End Sub
2.得到ListTemplate Collection
As SPListTemplateCollection = _site.GetCustomListTemplates(_web)
2: ListBox1.Items.Clear()
In listTemplates
4: ListBox1.Items.Add(listTemplate.Name)
5: Next
3.通过List template创建SPList
String)
2:
As SPListTemplateCollection = _site.GetCustomListTemplates(_web)
4:
As SPListTemplate = listTemplates(listTemplateName)
, listTemplate)
7:
End Sub