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

I need to copy my files from one document library to another document library which reside on another site and Document library contains number folders and sub folders.. The same structure should be maintained by destination library also. They should copy to same sub folders . This should be copied only when field in first document library having status approved? I have coded it in updated event receiver

Any answers will be greatly appreciated?

share|improve this question

closed as unclear what you're asking by Daniel Ziga, Robert Lindgren, PirateEric, Benny Skogberg, RJ Cuthbertson Sep 25 '13 at 20:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

5  
So what's the problem? –  SHug Oct 21 '11 at 13:13
2  
You'll need to provide some code if you're having issues –  Tim Gabrhel Oct 21 '11 at 13:15
2  
Which version are you using? Is Content Organizer an option? It does this for you without the need for custom code. –  Mike Oryszak Oct 21 '11 at 13:31

2 Answers 2

You have done the right thing for coding in Updated Event Receiver. Since the files must be copied from one document library to another on Status field being updated as approved (i.e. list item "Status" is approved), your code must be in ItemUpdated event receiver.

Code:

if(properties.AfterProperties["Status"] == "Approved") { // your code to copy from one document library to another. }

OR

SPListItem spitem = properties.ListItem;

if(spitem["Status"] == "Approved") { // your code to copy from one document library to another. }

share|improve this answer

You could try using the SPFile.MoveTo() method:

sourceFile.MoveTo(destinationUrl);

Also, here's a link to the MSDN page of this function if you'd like more information:

SPFile.MoveTo method

share|improve this answer
    
While this may answer the question, a little more context around your code or additional information relating to the function that you've suggested will help to make your answer more complete. –  RJ Cuthbertson Feb 15 '13 at 14:32

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