C#Sharepoiint 2010 - 如何重命名列表或文档库的标题和描述

时间:2016-10-31 08:48:54

标签: list sharepoint-2010 rename

我想在更多SiteCollection SharePoint中更改标题(名称)和现有列表或文档库的说明。我希望列表或文档库的名称采用网站集的名称。

我创建了一个改变这个的方法,但我有一个错误(

我的方法:

private void RenameLists(SPWeb web)
   {
       this.ExecuteUpgrade(web, () =>
        {
            SPList documentsLibraryList = web.Lists.TryGetList(documentLists.GetDocumentsLibraryName(web));

            if (documentsLibraryList.Title.ToString() == "Document Library")                
            {
                string oldValue = "Document Library";
                string newValue = (web.Title + " Documents").ToString();
                documentsLibraryList.Title.Replace(oldValue, newValue);
                documentsLibraryList.Update();
            }
        });
   }  

我的方法“GetDocumentsLibraryName”:

   public static string GetDocumentsLibraryName(SPWeb web)
    {
        return string.Format("{0} Documents", web.Title);
    }

但是当我调试时,我发现了一个错误:

消息:对象引用未设置为对象的实例

有什么想法吗?

致以最诚挚的问候,

0 个答案:

没有答案