In one of my previous post I had demonstrated how to, Download Large Files from SharePoint Online. While the file download is working perfectly fine, but, I was constantly getting the following error while trying to load/access it’s properties,

Value was either too large or too small for an Int32

Issue

Unable to access the properties of large files in SharePoint Online using CSOM.

Solution

Following is the code snippet I was using to access the properties of any SharePoint file using CSOM,

Now, the above piece of code is still working with smaller documents. It’s only with large files, that I was facing this issue.

To solve this, I started commenting out the given properties one by one, to check if one of them is causing the issue with large files. And, as it turned out, I finally got the culprit, FieldValuesAsHtml. When I omitted the loading of FieldValuesAsHtml, the code ran just fine . Here’s the working sample,

Key Takeaways

I omitted all the other properties and loaded only, FieldValuesAsHtml, still the issue remained! So the problem lies with this property only.

Previously, due to the 2GB limitation on the file size by SharePoint, I had only tested the above code with files of sizes less than 1GB. So this could be an old, untested issue.

Finally, though I got the code working for me, I still don’t have a proper explanation for it. If anybody has any idea as to why we cannot request this property for large files, then, please share. Would love to know the exact reason. 🙂