Hello,
But getting this error:
The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.Am I passing wrong parameter in SaveBinaryDirect.
try { AttachmentCreationInformation at = null; foreach (Attachment filename in itemSource.AttachmentFiles) { Microsoft.SharePoint.Client.File file = itemSource.ParentList.ParentWeb.GetFileByServerRelativeUrl(filename.ServerRelativeUrl); try { ctxSource.Load(file); ctxSource.ExecuteQuery(); } catch (Exception) { //throw; } var imageData = file.OpenBinaryStream(); //StreamReader fsReader = new StreamReader(file.OpenBinaryStream()); string url = ctxDestination.Url + "Lists/Dokumente1/Attachments/" + lstItem.Id + "/" +file.Name; Microsoft.SharePoint.Client.File.SaveBinaryDirect(ctxDestination, url, file.OpenBinaryStream().Value, true); //at = new AttachmentCreationInformation { FileName = file.Name, ContentStream = imageData.Value }; //lstItem.AttachmentFiles.Add(at); } lstItem.Update(); ctxDestination.ExecuteQuery(); }