Logo 
Search:

Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Moving files between document libraries

  Asked By: Evelyn    Date: Dec 13    Category: Sharepoint    Views: 2361

I wrote an event sink for a document library. I have all the code
working but one piece: If a field in the library is set to `Approved –
Final' I need to move the event file from that library to another
Document Library which is located in a sub-web of the parent web.
I understand that the `moveto' method will not work for files outside
the same site. Would I use the `add' method of the SPFileCollection ?
Here is the snippet of code I am trying to get to work but it keeps
error-ing with the Event Log message of "There is no file with that
URL in this web"

SPWeb site = new SPSite( <DestinationLibraryURL> ).OpenWeb();
byte[] binFile = <fileObjectToMove>.OpenBinary();
site.Files.Add(<DestinationLibraryURL>, binFile,true);

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on Moving files between document libraries Or get search suggestion and latest updates.




Tagged: