SharePoint Learnings

Home » SharePoint 2010 » SharePoint: Change Folder name programatically in SharePoint

SharePoint: Change Folder name programatically in SharePoint

Nadeem Yousuf January 12, 2012 SharePoint 2010

Following piece of code looks for a folder named "ABC" in Document Library and renames it to "New Name"

SPList list = web.Lists["Doc1"];
foreach (SPFolder folder in list.RootFolder.SubFolders)
{
    if (folder.Name.Equals("ABC"))
    {
        folder.Item["BaseName"] = "New Name";
        folder.Item.SystemUpdate();
    }
}

Share this

Share on FacebookTweet on TwitterPlus on Google+
« Prev Post
Next Post »

Search This Blog

profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

Popular Posts

  • SharePoint: REST API Calls uisng C#
    The code example shows how to make SharePoint REST API GET calls in C# using HttpWebRequest. The sample code assumes that the SharePoint Li...
  • SharePoint CSOM : Create Lookup column with additional field
    This post shows how to create a lookup column with additional field using SharePoint C# Client side object model code. I have two lists, E...
  • SharePoint: Limit folder content types. Change New Button Order
    Scenario: A SharePoint document library or list containing various content types as seen in the screenshot below: All Content Types ...
  • SharePoint: CSOM break folder permissions
    Consider a scenario where you need to break permissions of a folder using client object model (CSOM) in SharePoint. The code below creates...
  • SharePoint: Get Publishing Pages from inside folders
    I had few folders in a pages library which contained pages inside them.  PublishingWeb . GetPublishingPages ()  only gets pages present in...
  • SharePoint: Get Files from folder using JavaScript client object model
    The example below uses  SP . CamlQuery ()  to get items by setting  set_folderServerRelativeUrl  .  <script type = "text/javascri...
  • SharePoint: HasRights and Edit Control Block
    I recently found a bug in one of my codeplex projects Export Version History . A user was able to see the Export Version History option in ...
  • SharePoint PowerShell: Get files in Library
    Get the Name and Url of the files inside a SharePoint Document library using PowerShell: Code Example 1: $web = Get - SPWeb "http:...
  • SharePoint: Change Page Layout through code
    The following example changes the layout of a page to ArticleLeft.aspx. using ( SPSite site = new SPSite ( "http://aissp2013...
  • SharePoint: Update XSLTListViewWebPart properties
    Consider a web part page having an XSLTListViewWebpart on it and the requirement is to update its properties using PowerShell. In this exam...

Copyright © 2018 SharePoint Learnings | Template By HAFID Notes | Distributed By Blogger Templates