tags:

views:

24

answers:

0

Quick question about SharePoint.... I need to update an attachment on a list using the SharePoint sdk,but when ever I delete the old one, and add the new one, the new document is never added. Below is my code...

/* Delete the attachment first and create a new attachment.*/
            string fileName = newAttachmentName.Substring(0, newAttachmentName.IndexOf("."));
            //Delete Attachment
            SPAttachmentCollection attachments = item.Attachments;
            if (item.Attachments != null)
            {
                string oldfilename = attachments[0].ToString();

                attachments.DeleteNow(oldfilename);
                item.Update();
            }

            //AddAttachement(item, newAttachmentName, attachmentStream, true);
            attachments.Add(newAttachmentName, contents);
            ////attachments[0] = filename;
            item.Update();