本文介绍了CSOM File.MoveTo返回“不支持此操作”错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用SP 2013 CSOM中的File.MoveTo将文档从一个库移动到同一站点上的另一个库。这是我的代码:

I'm trying to move a document from one library to another library on the same site using File.MoveTo in SP 2013 CSOM. Here's my code:

using (ClientContext context = new ClientContext(sharePointUrl))
{
     Web web = context.Web;
     File file = item.File;
     context.Load(file);
     context.ExecuteQuery();
     file.MoveTo(destFileName, MoveOperations.Overwrite);
     context.ExecuteQuery();
}


看起来非常简单,但在context.ExecuteQuery()调用中,我收到错误消息"此操作不受支持。" 没有其他有用的信息。但是,当我尝试使用CopyTo而不是MoveTo时,它可以正常工作。 我宁愿使用MoveTo
,所以我不必删除代码中的源文件,但我必须这样做。 只是想知道是否有人知道为什么MoveTo可能会失败。谢谢。

Seems pretty straightforward, but on the context.ExecuteQuery() call, I'm getting the error message "This operation is not supported."  No other helpful info. However, when I try CopyTo instead of MoveTo, it works fine.  I'd rather use MoveTo so I don't have to delete the source file in my code, but I will I have to.  Just wondering if anyone has any insight as to why MoveTo might be failing. Thanks.

推荐答案


这篇关于CSOM File.MoveTo返回“不支持此操作”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 13:20