Programmatically create wiki page in SharePoint


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
Microsoft.SharePoint;
namespace
CreateWikiPage
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://serverName:1111/SitePages/Home.aspx"))
{
using (SPWeb web = site.RootWeb)
{
SPList list = web.Lists["A"];
SPFolder rootFolder = list.RootFolder;
SPFile wikiPage = rootFolder.Files.Add(String.Format("/{0}/{1}", rootFolder, "Home.aspx"), SPTemplateFileType.WikiPage);
SPListItem wikiItem = wikiPage.Item;
wikiItem[
SPBuiltInFieldId.WikiField] = "My Wiki Page Home";
wikiItem.UpdateOverwriteVersion();
}
}
}
}
}
Ebook Download
View all
Learn
View all