Public Function Add ( _ strWebUrl As String _ ) As SPWeb
Dim instance As SPWebCollection Dim strWebUrl As String Dim returnValue As SPWeb returnValue = instance.Add(strWebUrl)
public SPWeb Add ( string strWebUrl )
A string that contains the new Web site URL relative to the root Web site in the site collection. For example, to create a Web site at http://MyServer/sites/MySiteCollection/MyNewWebsite, specify MyNewWebsite, or to create a Web site one level lower at http://MyServer/sites/MySiteCollection/Website/MyNewWebsite, specify Website/MyNewWebsite.
http://MyServer/sites/MySiteCollection/MyNewWebsite
MyNewWebsite
http://MyServer/sites/MySiteCollection/Website/MyNewWebsite
Website/MyNewWebsite
The following code example creates a Web site within the current site collection.
Dim siteCollection As SPSite = SPControl.GetContextSite(Context) Dim subSites As SPWebCollection = siteCollection.AllWebs Dim mySite As SPWeb = subSites.Add("MyNewWebsite") mySite.Dispose()
SPSite oSiteCollection = SPContext.Current.Site; SPWebCollection collWebsites = oSiteCollection.AllWebs; SPWeb oWebsite = collWebsites.Add("Website/Subsite/MyNewSubsite"); 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 Best Practices: Using Disposable Windows SharePoint Services Objects.