How to programmatically Create SPListItem in a SPFolder
SPWeb web = mySite.OpenWeb();
SPList list = web.Lists["ListName"];
SPFolder f = web.GetFolder("http://[ServerName/sitename]/Lists/ListName/FolderName" );
if(f.Exists)
{
SPListItemCollection itemColl = list.Items;
SPListItem item = itemColl.Add(f.ServerRelativeUrl , SPFileSystemObjectType.File, null);
item["Title"] = "Added from Code";
item.Update();
}
Comments
Post a Comment