Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I programmatically move a document from one document library to another while preserving metadata? Preferably using the server OM.

share|improve this question
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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