I want to read the file attached to a item in share point and store it into a local file.Is it possible?


Yes it's possible , you can download a file from list item via CSOM as the following

using (var clientContext = new ClientContext(url))

 var list = clientContext.Web.Lists.GetByTitle(listTitle);
 var listItem = list.GetItemById(listItemId);
 clientContext.Load(listItem, i => i.File);

 var fileRef = listItem.File.ServerRelativeUrl;
 var fileInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);
 var fileName = Path.Combine(filePath,(string)listItem.File.Name);
 using (var fileStream = System.IO.File.Create(fileName))

Ref : How to download/upload files from/to SharePoint online using CSOM?

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.