复制共享点文件夹错误,指出文件夹无效

时间:2018-10-03 10:43:07

标签: c# sharepoint

我有以下代码对Move有效,但对复制无效

// relativeSourceFolderUrl = "/SubSeries/DEV010/files/dev010-007-2018/parent/copyThisFolder"
// relativeDestinationFolderUrl= "/SubSeries/DEV010/files/dev010-007-2018/parent/child"
// fileName = "copyThisFoler"
// moveItem = false

public Folder MoveOrCopyFolder(String relativeSourceFolderUrl, String relativeDestinationFolderUrl, String fileName, bool moveItem)
{
    Folder folder = ClientContext.Web.GetFolderByServerRelativeUrl(relativeDestinationFolderUrl);

    // Check if file or folder exists and alter name

    fileName = CheckFileOrFolderExistsInFolder(fileName, folder, false);
    // In this case the function returns a fileName of "copyThisFolder"
    var file = ClientContext.Web.GetFileByServerRelativeUrl(relativeSourceFolderUrl);
    ClientContext.Load(file.ListItemAllFields);
    ClientContext.ExecuteQuery();
    if (moveItem)
        file.MoveTo(relativeDestinationFolderUrl + "/" + fileName, MoveOperations.None);
    else
        file.CopyTo(relativeDestinationFolderUrl + "/" + fileName, false);

    ClientContext.ExecuteQuery();            

    return null;
}

在此行中断

  

file.CopyTo(relativeDestinationFolderUrl +“ /” + fileName,false);

错误是

  

其他信息:URL'/ SubSeries / DEV010 / files / dev010-007-2018 / parent / copythisfolder'无效。它可能引用了不存在的文件或文件夹,或者引用了不在当前网站中的有效文件或文件夹。

移动有效,但奇怪的是,类似的代码不适用于复制。

1 个答案:

答案 0 :(得分:0)

最后我使用了这篇文章: https://sharepoint.stackexchange.com/questions/97471/copy-all-items-in-a-folder-to-another-location/250233?noredirect=1#comment266907_250233

这使我想到了这个解决方案:

to Crete a circle out of an