开发者

Programmatically changing name of SPFolder

I was wondering whether it is possible to programmatically change the name of an SPFolder after it has been created?

e.g.

foreach (SPFolder folder in list.RootFolder.SubFolders)
{
    if (folder.Name.Equals("blah"))
    {
        // set the name of the folder to something else
        folder.Name = "blah 2.0";
    }
}

Googling so far suggested t开发者_StackOverflowhat MoveTo is the only way of doing so. There are a lot of items inside the folder so I'm reluctant to moving it unless there is absolutely no other ways.

Thanks.


I ended up using MoveTo as there was no other ways of doing this.


In a Document Library the field Name of an item (folder) has StaticName = FileLeafRef. So what really worked for me is

folder.Item[SPBuiltInFieldId.FileLeafRef] = "The new name";
folder.Item.Update();


when you have an SPFolder object, you can do it like this:

folder.item["Title"] = "blah 2.0";
folder.item.SystemUpdate();'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜