I m trying to upload large file using CSOM code. Code is throwing the following error -

Specified argument was out of the range of valid values. Parameter name: bytesToCopy

clientContext.RequestTimeout = 10000000;
var fileCreationInformation = new FileCreationInformation();
fileCreationInformation.ContentStream = memoryStream;
fileCreationInformation.Overwrite = false;
fileCreationInformation.Url = fullFilePath;
file = fldr.Files.Add(fileCreationInformation);


I am referring to the following MSDN help. I am using the ContentStream property for FileCreationInformation. Upload large files sample app for SharePoint

  • Where are you using this? On premise or office 365?
    – Akhoy
    Jul 21, 2015 at 9:18
  • Use the REST api or custom web part of file upload for upload the large file
    – sachin
    Jul 21, 2015 at 9:21
  • Forgot to mention it, I have on-premise SharePoint app
    – bkk
    Jul 21, 2015 at 9:55
  • Have you checked this? social.msdn.microsoft.com/Forums/en-US/…
    – Akhoy
    Jul 21, 2015 at 9:59

1 Answer 1


I had the same issue.

My code was

var fileCreationInformation = new FileCreationInformation();
fileCreationInformation.ContentStream = memorystream;

The above code was throwing error to me. I resolved it by converting MemoryStream object to Stream object. So the new code is,

var fileCreationInformation = new FileCreationInformation();
byte[] documentBytes = memorystream.ToArray();
Stream s = new MemoryStream(documentBytes);
fileCreationInformation.ContentStream = s;  

This fixed my issue. Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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