Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 使用ClientContext重命名Sharepoint文件夹_Asp.net_Sharepoint - Fatal编程技术网

Asp.net 使用ClientContext重命名Sharepoint文件夹

Asp.net 使用ClientContext重命名Sharepoint文件夹,asp.net,sharepoint,Asp.net,Sharepoint,我已经被困了一段时间了。我需要使用ClientContext重命名SharePoint文件夹。我创建了这样一个函数: Public Function renameFolder(_folders As ListItemCollection, _newFolderName As String) As Boolean Try Using _clientContext As New ClientContext(vSharepointSite) AddHan

我已经被困了一段时间了。我需要使用ClientContext重命名SharePoint文件夹。我创建了这样一个函数:

Public Function renameFolder(_folders As ListItemCollection, _newFolderName As String) As Boolean
    Try
        Using _clientContext As New ClientContext(vSharepointSite)
            AddHandler _clientContext.ExecutingWebRequest, AddressOf vClaimsHelper.clientContext_ExecutingWebRequest
            Dim _folder = _folders(0)
            _folder.Item("Title") = _newFolderName
            _folder.Item("FileLeafRef") = _newFolderName
            _folder.Item("DisplayName") = _newFolderName
            _folder.Update()

            _clientContext.ExecuteQuery()

        End Using
        Return True
    Catch ex As Exception
        Return False
    End Try
End Function
此函数接受文件夹集合(实际上我只传递了一个文件夹集合)和新文件夹名称。该函数执行良好。在执行
执行任务之后检查
\u文件夹
,一切看起来都与预期的一样。但是,SharePoint中不会发生任何事情,这意味着文件夹名称仍然是原始名称

有什么建议吗

致以最良好的祝愿……新年快乐!!!!
Ariel

使用
BaseName
字段重命名文件夹

_folder.Item("BaseName") = _newFolderName

确保
列表项
\u示例中的文件夹
变量)与
文件夹
对象关联

如何确定
列表项
是否与
文件夹
对象关联 如何使用SharePoint CSOM重命名文件夹 以下示例演示如何重命名
文件夹

Public Sub RenameFolder(folder As Folder, folderName As String)
    Dim ctx = folder.Context
    Dim folderItem = folder.ListItemAllFields
    folderItem("FileLeafRef") = folderName
    folderItem("Title") = folderName
    folderItem.Update()
    ctx.ExecuteQuery()
End Sub
用法


谢谢你的回复。我忘了提到我们仍然在使用Microsoft.Sharepoint的versoin 14和客户端库。无论如何,你的回答强烈地激励我迁移到版本15。顺致敬意,
Public Sub RenameFolder(folder As Folder, folderName As String)
    Dim ctx = folder.Context
    Dim folderItem = folder.ListItemAllFields
    folderItem("FileLeafRef") = folderName
    folderItem("Title") = folderName
    folderItem.Update()
    ctx.ExecuteQuery()
End Sub
    Using ctx As New ClientContext(webUrl)
        Dim folder = ctx.Web.GetFolderByServerRelativeUrl(folderUrl)
        RenameFolder(folder, "Orders")
    End Using