3

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

/sites/test/_layouts/15/start.aspx#/**1235**/Forms/AllItems.aspx

I would like to update this URL and change the

12345

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

something like :

 /sites/test/_layouts/15/start.aspx#/**TEST**/Forms/AllItems.aspx

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();
lst.Update();

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

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)
0

I did it on C# with this below code

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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