SPWebCollection.Names property

Gets an array that contains the site-relative URLs of all the websites in the collection.

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

Syntax

'Declaration
Public ReadOnly Property Names As String()
    Get
'Usage
Dim instance As SPWebCollection
Dim value As String()

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

Property value

Type: []
A string array that contains the site-relative URLs.

Examples

The following code example displays the URL of each site in the current site collection.

This example requires using directives (Imports in Visual Basic) for the Microsoft.SharePoint and Microsoft.SharePoint.Utilities namespaces.

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>");
}

See also

Reference

SPWebCollection class

SPWebCollection members

Microsoft.SharePoint namespace