Check the MSDN page on using the SPWebCollection.Add method (which you are using here): http://msdn.microsoft.com/en-us/library/ms412285.aspx
It has an example code there doing exactly what you are looking to do:
// If a subsite by that name exists, open it.
string[] webs = parentWeb.Webs.Names;
if (webs != null && Array.IndexOf(webs, childName) >= 0)
{
childWeb = parentWeb.Webs[childName];
}
// Otherwise, create the subsite.
if (childWeb == null)
{
string title = "Wiki";
string desc = "A place to capture knowledge.";
uint lcid = parentWeb.Language;
string templateName = "WIKI#0";
childWeb = parentWeb.Webs.Add(childName, title, desc, lcid, templateName, false, false);
}
Above is just a snippet of what's there, but I believe this is what you are looking for.
Brandon Atkinson
Blog: http://brandonatkinson.blogspot.com
No comments:
Post a Comment