How do I update a file's version in a SharePoint repository using .NET?

45 Views Asked by At

I'm trying to copy files from one SharePoint repository to another while retaining each file's history. While I can successfully transfer the file data (all PDFs render and text files are intact), the version history defaults to that set in the target repository.

Suppose a file on the host repository sits at Version 3. I want it to have a Version value of 3 in the target repository after copying it; however, it will be either 1 (if the file is new) or 2 (if the file exists with no updates).

So far, I've tried using CSOM and CAML queries to access and copy files. Since the metadata isn't preserved, can I instead insert a specific version value? I've looked into this with both CSOM and CAML to little luck. Do you know how I may do this?

1

There are 1 best solutions below

0
RaytheonXie-MSFT On

You could use following flow to keep old version while move the file. Please make a reference

https://powerusers.microsoft.com/t5/Building-Flows/Copy-file-to-location-maintaining-version-history/td-p/274223