SPDocumentLibrary 类
代表Microsoft SharePoint Foundation中的文档库。
继承层次结构
System.Object
Microsoft.SharePoint.SPSecurableObject
Microsoft.SharePoint.SPList
Microsoft.SharePoint.SPDocumentLibrary
Microsoft.SharePoint.SPPictureLibrary
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Class SPDocumentLibrary _
Inherits SPList
用法
Dim instance As SPDocumentLibrary
public class SPDocumentLibrary : SPList
备注
若要获取SPDocumentLibrary对象,请转换文档库中,为给定的列表,如下面的示例中所示。
Dim documentLibrary As SPDocumentLibrary = CType(list, SPDocumentLibrary)
SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList;
示例
下面的代码示例循环访问所有网站和其列表,并排除目录或表单库,将显示网站和列表中,名称以及每个文档库中每个项的文件名。
此示例假定存在包含标签控件的 .aspx 页。
此示例要求对Microsoft.SharePoint和Microsoft.SharePoint.Utilities命名空间的using指令 (在 Visual Basic 中的Imports )。
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim sites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb
For Each site In sites
Dim lists As SPListCollection = site.Lists
Dim list As SPList
For Each list In lists
If list.BaseType = SPBaseType.DocumentLibrary Then
Dim docLibrary As SPDocumentLibrary =
CType(list, SPDocumentLibrary)
If Not docLibrary.IsCatalog Then
If list.BaseTemplate <> SPListTemplateType.XMLForm Then
Dim docLibItems As SPListItemCollection =
docLibrary.Items
Dim docLibItem As SPListItem
For Each docLibItem In docLibItems
Label1.Text += SPEncode.HtmlEncode(site.Name)
& " :: " _
& SPEncode.HtmlEncode(list.Title)
& " :: " _
& SPEncode.HtmlEncode(docLibItem("Title"))
& "<BR>"
Next docLibItem
End If
End If
End If
Next list
Next site
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{
SPListCollection collLists = oWebsite.Lists;
foreach (SPList oList in collLists)
{
if (oList.BaseType == SPBaseType.DocumentLibrary)
{
SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList;
if (!oDocumentLibrary.IsCatalog && oList.BaseTemplate !=
SPListTemplateType.XMLForm)
{
SPListItemCollection collListItems = oDocumentLibrary.Items;
foreach (SPListItem oListItem in collListItems)
{
Label1.Text += SPEncode.HtmlEncode(oWebsite.Name) +
" -- " +
SPEncode.HtmlEncode(oList.Title) + " -- " +
SPEncode.HtmlEncode(oListItem["Title"]) +
"<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 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。