sharepoint 2007 列表的内部名称修改

 try
        {
            //we need the privileges to execute the moveto command
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                //connect to the site collection
                using (SPSite mySite = new SPSite("http://server"))
                {
                    //open the relevant site
                    using (SPWeb myWeb = mySite.OpenWeb("TestSite"))
                    {
                        //loop through the lists
                        foreach (SPList list in myWeb.Lists)
                        {
                            //when we find the correct list, change the name
                            if (list.RootFolder.Name == "TestList")
                            {
                                //move the root folder
                                list.RootFolder.MoveTo(list.RootFolder.Url.Replace("TestList", "TestList_New"));
                            }
                        }
                    }
                }
            });

            Console.WriteLine("Done");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error: {0}", ex);
        }

        Console.ReadLine();

本文摘自:http://heathesh.com/post/2010/01/28/Change-the-URL-of-a-list-in-SharePoint-2007.aspx

posted @ 2010-10-08 10:28  醉清风  阅读(376)  评论(0编辑  收藏  举报