How can I programmatically move a document from one document library to another while preserving metadata? Preferably using the server OM.
3 Answers
I don't have the source code handy but the SPListItem.Copy() method would probably be a good place to start - http://msdn.microsoft.com/en-us/library/ms455492.aspx.
There is SPFile.MoveTo() method which moves the file within the same site: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfile.moveto.aspx
I know you have expressed an interest in using the server object model, but there is also the Copy.asmx web service (specifically the CopyIntoItems() method). I, myself, don't like the Copy web service, because it creates a link back to the original document. I just wanted to provide another alternative.