I have created a library programmatically within a content type my URL is :


I would like to update this URL and change the


by something else on my C# code (a string value that i get somewhere else).

something like :


I success to change the Title of the library easily but not the URL.

SPList lst = web.Lists[oldVal];
lst.Title = properties.AfterProperties["CorporateName"].ToString();

I searched and read many way to do it within Sharepoint Designer, but I didn't find the perfect solution to do it on Visual Studio.

2 Answers 2


You can try this to change the URL:

Add-PSSnapin Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

$libOriginalUrl = "/Lists/YourLibName1";
$libNewUrl = "/YourLibName2";
$web = Get-SPWeb -Identity http://....

$lib = $web.GetList($web.Url + $libOriginalUrl)
$rootFolder = $lib.RootFolder;
$rootFolder.MoveTo($web.Url + $libNewUrl)

I did it on C# with this below code

SPList lst = web.Lists[properties.ListItem["Name"].ToString()];
SPFolder folder = web.Folders[lst.RootFolder.Url];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.