0
votes

Creating a SP 2013 Online app using CSOM. I m creating a custom ASPX page in SP designer, and to insert and update item to a SharePoint list. Earlier the List input form was developed InfoPath 2013, where file Attachment control was used. Since the code is not rewritten using ClientContext, can someone tell me how it should be done?

1

1 Answers

0
votes

You might want to Check out the SharePoint Stackexchange for SharePoint specific questions.

List list = web.Lists.GetByTitle("listtitle");
ListItem item = list.GetItemById(1);
var attachment = new AttachmentCreationInformation();
attachment.FileName = "fileName";
attachment.ContentStream = new MemoryStream(System.IO.File.ReadAllBytes("streamFile"));
Attachment att = item.AttachmentFiles.Add(attachment);                                        
context.Load(att);                                     
context.ExecuteQuery();  

https://sharepoint.stackexchange.com/questions/144814/how-to-attach-files-to-list-item-using-client-object-model