I was blocked by an issue of document version number. The customer wants to move a document from one document library to another. After the document is moved, version number should be kept the same and metadata values of each version should also be kept.
File.MoveTo(string newUrl) method can move file and keep the same version number but lose the metadata in previous versions. Only the latest version has metadata values. Also this method cannot move file cross site collections.
Following is my solution:
1. Upload all the versions along with metadata to the new location and then delete the old file.
2. Update document version number in database directly.
Finally the solution works well, but I don't know if step2 will impact any other default logic in SharePoint system. Below is the logic to update version number.
SqlConnection cn = new SqlConnection(connStr);
cmd = cn.CreateCommand();
View Complete Post