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