惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
Y
Y Combinator Blog
雷峰网
雷峰网
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
有赞技术团队
有赞技术团队
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
博客园 - 聂微东
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
罗磊的独立博客
M
MIT News - Artificial intelligence
B
Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
大猫的无限游戏
大猫的无限游戏
V
V2EX
I
InfoQ
The Cloudflare Blog
Cloudbric
Cloudbric
Stack Overflow Blog
Stack Overflow Blog
V
Vulnerabilities – Threatpost
博客园_首页
Google DeepMind News
Google DeepMind News
Jina AI
Jina AI
T
The Exploit Database - CXSecurity.com
宝玉的分享
宝玉的分享
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
The Register - Security
The Register - Security
美团技术团队
K
Kaspersky official blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tor Project blog
P
Privacy International News Feed
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
博客园 - 三生石上(FineUI控件)
Cyberwarzone
Cyberwarzone
Vercel News
Vercel News
Cisco Talos Blog
Cisco Talos Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cisco Blogs
G
Google Developers Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
A
Arctic Wolf
MongoDB | Blog
MongoDB | Blog

博客园 - vuejs3

More on SQL Server Service Broker [转]Android试验:如果View的ID相同会出现什么效果? 父子关系排序,无确定根节点 Silverlight 操作技巧 [文摘]怎么使用Sticky Footer代码(让页脚紧贴页面底部的方法) Sharepoint development toolbox 在文档库中隐藏多文件上传/Disable the Upload Multiple Document option in Document Library - vuejs3 [转]SharePoint Document Library and List – File Upload ASP.NET 2.0 TreeView控件在IE7中断开的连接线 Team Foundation Server讲义 通过CertEnroll在CA上(1创建证书请求2得到证书3安装证书) 如何在WSS中利用KeywordQuery创建搜索查询 SharePoint Web Service的身份验证 SharePoint开发中对ListViewWebPart的几个操作 【转】免费SharePoint资源 Enum操作技巧 LINQ概述-通用和便利的信息查询方式 NetShopForge网上商店程序(VB)源码—讨论-发布 Microsoft AJAX添加自定义智能感知(intellisense)
通过对象模型上传List Template - vuejs3 - 博客园
vuejs3 · 2009-09-10 · via 博客园 - vuejs3

List template文件放在Site Actions – Galleries  - List templates中。

1.上传.stp文件

   1: Private Sub UploadTemplates(ByVal _site As SPSite)
   2:     Dim directory As String = String.Format("{0}\ListTemplates", Application.StartupPath)
   3:     Try
   4:         If System.IO.Directory.Exists(directory) Then
   5:             Dim templates As String() = System.IO.Directory.GetFiles(directory, "*.stp", System.IO.SearchOption.TopDirectoryOnly)
   6:             Dim listTemplates As SPDocumentLibrary = TryCast(_site.GetCatalog(SPListTemplateType.ListTemplateCatalog), SPDocumentLibrary)
   7:             If Not IsNothing(listTemplates) Then
   8:                 For Each template As String In templates
   9:  
  10:                     Dim fileInfo As New System.IO.FileInfo(template)
  11:                     Dim query As New SPQuery()
  12:                     query.Query = String.Format("<Where><Eq><FieldRef Name='FileLeafRef'/>" & "<Value Type='Text'>{0}</Value></Eq></Where>", fileInfo.Name)
  13:                     Dim existingTemplates As SPListItemCollection = listTemplates.GetItems(query)
  14:  
  15:                     Dim Ids As Integer() = New Integer(existingTemplates.Count - 1) {}
  16:                     For i As Integer = 0 To existingTemplates.Count - 1
  17:                         Ids(i) = existingTemplates(i).ID
  18:                     Next
  19:                     For j As Integer = 0 To Ids.Length - 1
  20:                         listTemplates.Items.DeleteItemById(Ids(j))
  21:                     Next
  22:  
  23:                     Dim stp As Byte() = System.IO.File.ReadAllBytes(template)
  24:                     listTemplates.RootFolder.Files.Add(fileInfo.Name, stp)
  25:                 Next
  26:             End If
  27:         End If
  28:     Catch ex As Exception
  29:  
  30:     End Try
  31: End Sub

2.得到ListTemplate Collection

   1: Dim listTemplates As SPListTemplateCollection = _site.GetCustomListTemplates(_web)
   2:  ListBox1.Items.Clear()
   3: For Each listTemplate As SPListTemplate In listTemplates
   4:     ListBox1.Items.Add(listTemplate.Name)
   5: Next

3.通过List template创建SPList

   1: Private Sub CreateList(ByVal _site As SPSite, ByVal _web As SPWeb, ByVal listTemplateName As String)
   2:  
   3:     Dim listTemplates As SPListTemplateCollection = _site.GetCustomListTemplates(_web)
   4:  
   5:     Dim listTemplate As SPListTemplate = listTemplates(listTemplateName)
   6:     _web.Lists.Add(listTemplateName, "description", listTemplate)
   7:  
   8: End Sub