How to Replace an Existing Folder Using SharePoint CSOM API

Anonymous
2023-05-29T09:13:57+00:00

Hi all,

I'm trying to copy a folder in SharePoint using the API, but I'm having trouble finding the option to replace an existing folder if it already exists. I've tried using ‘MoveCopyUtil.CopyFolderByPath’ to copy the folder, but I can't seem to find a way to overwrite the destination folder if it already exists. I see that there is a 'KeepBoth' option, but what I really want is to replace the existing folder.

Interestingly, I noticed that the "Copy folder" action in Power Automate offers the option to overwrite a destination folder if it already exists.

Is there any way to achieve the same thing using SharePoint API? Any help or guidance would be greatly appreciated! Thanks in advance.

Microsoft 365 and Office | SharePoint | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-05-29T10:37:05+00:00

    Hi

    In SharePoint CSOM API, there is KeepBoth only in MoveCopyOptions Class.

    Power Automate Connector for SharePoint provideIf another folder is alreadyParameter****inCopy folder action ,so SharePoint Power Automate offers the option to overwrite a destination folder.

    Should you try to test SharePoint Rest API? In my opinion, SharePoint Rest API provide Replace Parameter very likely.

    May I suggest accord with your requirement? since our category focus on general troubleshooting and built-in features in Microsoft 365 and Office, and we have a dedicated channel : Questions - Microsoft Q&A related queries. For you to be assisted properly, we sincerely recommend you go to that community and post a new thread. You can click "Ask a question" to post a question there.

    Best Regards,

    Was this answer helpful?

    0 comments No comments