No one has seen this error before? Google's not yielding much of any use.

The folder that would hold URL '/site/newsite' does not exist on the server.

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Thursday, 16 June 2011 11:52 AM
To: ozMOSS
Subject: RE: SPWebCollection Add Method

OK I'm really close now.

Got past the parent URL issue.

String sitePath = currentPublishingSite.Web.ServerRelativeUrl.Substring(1);

Got past the nLCID parameter by changing Locale.ID to Language.

uint webLang = siteCollection.RootWeb.Language;

Now I'm getting the following and have already tried pre/appending slashes to 
the URL with no luck.

The folder that would hold URL '/teams/school/AboutUs' does not exist on the 
server.
at Microsoft.SharePoint.Library.SPRequestInternalClass.CreateWeb(String 
bstrUrl, String bstrTitle, String bstrDescription, UInt32 nLCID, String 
bstrWebTemplate, Boolean bCreateUniqueWeb, Boolean bConvertIfThere, Guid& 
pgWebId, Guid& pgRootFolderId, Boolean bCreateSystemCatalogs)
at Microsoft.SharePoint.Library.SPRequest.CreateWeb(String bstrUrl, String 
bstrTitle, String bstrDescription, UInt32 nLCID, String bstrWebTemplate, 
Boolean bCreateUniqueWeb, Boolean bConvertIfThere, Guid& pgWebId, Guid& 
pgRootFolderId, Boolean bCreateSystemCatalogs)

Do I need to create a container for the subsite first? Or is it referring to a 
physical folder (feature) in the hive?

Updated source:

      private void CreateSubsites(PublishingWeb currentPublishingSite)
      {
          if (currentPublishingSite.IsRoot)
          {
              using (SPSite siteCollection = new 
SPSite(SPContext.Current.Web.Url))
              {
                  // Get the parent site's relative path and trim leading slash!
                  String sitePath = 
currentPublishingSite.Web.ServerRelativeUrl.Substring(1);
                  // Inherit Language from parent. NOT the LCID as expected!
                  uint webLang = siteCollection.RootWeb.Language;
                  // Set template name
                  String webTemplate = _siteTemplateNamePrefix + "0";

                  using (SPWeb web = siteCollection.OpenWeb())
                  {
                      //Declare our site vars
                      String webName = "AboutUs";
                      String webUrl = String.Format("{0}/{1}", sitePath, 
webName);
                      String webTitle = "About Us";
                      String webDesc = "More information about the school";

                      // Create the site
                      using (SPWeb newWeb = 
SPContext.Current.Site.AllWebs.Add(webUrl, webTitle, webDesc, webLang, 
webTemplate, false, false))
                      {
                          // Perform any additional mods here
                      }
                  }
              }

          }
      }

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to