我有以下代码对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'无效。它可能引用了不存在的文件或文件夹,或者引用了不在当前网站中的有效文件或文件夹。
移动有效,但奇怪的是,类似的代码不适用于复制。
答案 0 :(得分:0)
这使我想到了这个解决方案:
to Crete a circle out of an