Wednesday, April 10, 2013
Add/Move ListItems to a folder in SharePoint List, adding folders if needed
/// Adding Items under folder in List
SPList oList = web.Lists["ListName"];
SPListItemCollection items = oList.Items;
SPListItem item = items.Add("/sites/[webname]/Lists/[ListName]/[FolderName]",
SPFileSystemObjectType.File);
item["Title"] = "Something";
item.Update();
///// Moving Listitems to different folder in same list
SPListItemCollection items = oList.Items;
foreach (SPListItem item in items)
{
SPFile file = web.GetFile(item.Url.ToString());
file.MoveTo(string.Format("Lists/[ListName]/{0}/{1}_.000", "FolderName", item["ID"].ToString()));
item.Update();
}
/// Creating Folders if needed
oFolder = oList.Items.Add(oList.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, FolderName);
newFolder.Update();
oList.Update();
Tuesday, April 9, 2013
Monday, April 8, 2013
SharePoint Best practises
http://msdn.microsoft.com/en-us/library/ee557257.aspx
no offense meant!
Hilarious comment at the bottom, that was just going around in my head.
no offense meant!
Hilarious comment at the bottom, that was just going around in my head.
Subscribe to:
Posts (Atom)