Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. SPFolder attachmentsFolder = web.Folders["Lists"].SubFolders["List Name"].SubFolders["Attachments"].SubFolders[properties.ListItem.ID.ToString()];
  2. foreach (SPFile file in attachmentsFolder.Files)
  3. {
  4. byte[] binFile = file.OpenBinary();
  5. duplicate.Attachments.AddNow(file.Name, binFile);
  6. }
  7.  
  8. web.Folders["Lists"].SubFolders["List Name"].SubFolders["Attachments"].SubFolders[properties.ListItem.ID.ToString()];
  9.  
  10. SPList objList = web.Lists["MyList"];
  11.  
  12. if(objList != null) {
  13. // Get the item by ID
  14. SPListItem objItem = objList.GetItemById(properties.ListItem.ID);
  15.  
  16. if(objItem != null) {
  17. // Get the attachments of the item
  18. SPAttachmentCollection objAttchments = objItem.Attachments;
  19.  
  20. //... code for copying attachements
  21.  
  22. }
  23. else {
  24. //Log Error
  25. }
  26. }
  27. else {
  28. //Log Error
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement