hi im using method for copy or move file on sharepoint. but i want to ask how to implement when it's duplicated it automatically replace and update version?

i've been try with this function but it's always

Microsoft.SharePoint.Client.ServerException: 'The destination file already exists

public void CopyFile(string SrcUrl, string DestUrl)
        MoveCopyOptions option = new MoveCopyOptions();
        option.KeepBoth = false;

And my src


and my Destination file


1 Answer 1


You can create a object of MoveCopyOptions that has boolean property KeepBoth. To handle similar file names you can set MoveCopyOptions. If you want to preserve both file after copying/moving set MoveCopyOptions.KeepBoth to true, else make it false.

  • hi i've been change this but doesn't work did im wrong ,i've been set to true for overwrite MoveCopyOptions option = new MoveCopyOptions(); option.KeepBoth = true; MoveCopyUtil.CopyFile(this.clientContext,SrcUrl,DestUrl,true,option); this.clientContext.ExecuteQuery(); Sep 8, 2020 at 1:40
  • hi @Akshay Randive i've been update why still error. Sep 8, 2020 at 7:10
  • I am not sure why this is not working. Can you try setting Overwite false and KeepBoth false Sep 8, 2020 at 10:58
  • yes sir i've been try setting overwrite false and keepboot false.but doesn't work this function. im using sharepoint 2016 is that work with latest CSOM? Sep 8, 2020 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.