SPSite.AllWebs 属性

Gets the collection of all Web sites that are contained within the site collection, including the top-level site and its subsites.

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Property AllWebs As SPWebCollection
    Get
用法
Dim instance As SPSite
Dim value As SPWebCollection

value = instance.AllWebs
public SPWebCollection AllWebs { get; }

属性值

类型:Microsoft.SharePoint.SPWebCollection
An SPWebCollection object that represents the Web sites.

备注

Best practice is to dispose explicitly of individual Web sites that are retrieved from the collection that is returned through the AllWebs property.

示例

The following code example displays in a console application the number of Web sites in a site collection and their URLs.

Dim siteCollection As New SPSite("http://" + System.Environment.MachineName)
Dim websiteCollection As SPWebCollection = siteCollection.AllWebs

Console.WriteLine("Count: {0}", websiteCollection.Count) 

siteCollection.Dispose()
using(SPSite oSiteCollection = new SPSite("http://" + System.Environment.MachineName))
{
    SPWebCollection collWebsites = oSiteCollection.AllWebs;
    Console.WriteLine("Count: {0}", collWebsites.Count);

    foreach (SPWeb oWebsite in collWebsites)
    {
        Console.WriteLine("Web site: {0}", oWebsite.Url);
        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.

另请参阅

引用

SPSite 类

SPSite 成员

Microsoft.SharePoint 命名空间