共用方式為


SPWebCollection.Names property

取得包含在集合中的所有網站的網站與相對 Url 的陣列。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public ReadOnly Property Names As String()
    Get
'用途
Dim instance As SPWebCollection
Dim value As String()

value = instance.Names
public string[] Names { get; }

Property value

Type: []
包含網站相對 Url 的字串陣列。

Examples

下列程式碼範例會顯示目前的網站集合中每個網站的 URL。

這個範例需要Microsoft.SharePointMicrosoft.SharePoint.Utilities命名空間using指示詞 (在 Visual Basic 中的Imports )。

Dim siteCollection As SPSite = SPContext.Current.Site 
Dim webSites As SPWebCollection = siteCollection.AllWebs
Dim names As String() = webSites.Names
Dim name As String

For Each name In  names

    Response.Write(SPEncode.HtmlEncode(name) & "<BR>")

Next name
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
string[] strNames = collWebsites.Names;
foreach (string strName in strNames)
{
    Response.Write(SPEncode.HtmlEncode(strName) + "<BR>");
}

請參閱

參照

SPWebCollection class

SPWebCollection members

Microsoft.SharePoint namespace