Copy attachements from one SharePoint list item to another




Using this method you can copy attachments from one list item to another. You can add it to SharePoint workflow or any other action.

public void CopyItem(SPListItem srcItem, SPListItem destItem) 
        { 
            foreach (string attachmentName in srcItem.Attachments) 
            { 
                SPFile file = srcItem.ParentList.ParentWeb.GetFile(srcItem.Attachments.UrlPrefix + attachmentName); 
                byte[] data = file.OpenBinary(); 
                destItem.Attachments.Add(attachmentName, data); 
            } 
            destItem.Update(); 
        }

 




No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment





MarkiMarta.com. Notes of web-specialist
Since 2009
18+