private void AddAttachments(ListItem item, XmlNode newNode) { AttachmentCreationInformation attInfo = new AttachmentCreationInformation(); //attachment data is in Attachments/Attachment XmlNodeList attachments = newNode.SelectNodes("Attachments/Attachment"); foreach (XmlNode attachment in attachments) { //get file attributes and file bytes if (string.IsNullOrEmpty(attachment.InnerText)) { return; } string attachmentName, attachmentExtension; int attSize; byte[] fileData; Base64Helper.GetBase64Values(attachment.InnerText, out attachmentName, out attachmentExtension, out attSize, out fileData); attInfo.FileName = string.Format("{0}_{1}", DateTime.Now.ToString("yyyyMMddHHmmssfffff"), attachmentName); attInfo.ContentStream = new MemoryStream(fileData); item.AttachmentFiles.Add(attInfo); } }