I'm trying to create a site programmatically using a console application, but have been getting an exception whenever I try to add a new SPWeb "The folder that would hold URL'/sites/[sitename]' does not exist on the server."
How do I go about creating this folder? I was under the impression that the SPWebCollection.Add()
method would create the necessary paths.
The code I'm using is
SPSite site;
SPWeb web;
SPSecurity.RunWithElevatedPriviliges(delegate()
{
site = new SPSite([url]);
web = site.AllWebs.Add("sites/[sitename]", "title", "description", 1033, "STS#1", false, false);
});
Thanks!