我有一个名称很长的文件夹名称列表。是否可以仅更改SharePoint文档库中文件夹的内部名称,这将减少网址的长度?
答案 0 :(得分:0)
我们可以添加新列来存储旧文件夹名称,然后使用下面的代码设置更改文档库中的文件夹名称。
string targetSiteURL = @"https://xx.sharepoint.com/sites/xx";
var login = "xx@xxx.onmicrosoft.com";
var password = "xxx";
var securePassword = new SecureString();
foreach (char c in password)
{
securePassword.AppendChar(c);
}
SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(login, securePassword);
ClientContext ctx = new ClientContext(targetSiteURL);
ctx.Credentials = onlineCredentials;
var list = ctx.Web.Lists.GetByTitle("Documents");
var folderItem = list.GetItemById(12);
folderItem["FileLeafRef"] = "TestFolder";
folderItem.Update();
ctx.ExecuteQuery();