Sharepoint Version: 2016

I have tried many solutions but still am failing. One site which had a possible solution was: http://www.stuartroberts.net/index.php/2014/05/09/sending-large-data-csom/ but when I go to use:

    var fci = new FileCreationInformation
                Url = relativeItemUrl,
                ContentStream = stream,
                Overwrite = true

I end up getting "'FileCreationInformation' does not contain a definition for 'ContentStream'" even though I am using "Microsoft.SharePoint.Client" in my project.

I tried:

    using (FileStream fs = new FileStream(pathToFile, FileMode.Open))
           Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, @"/" + number + @"/" + fileToAdd, fs, true);

which ended up just giving me a conflict error after about 3 minutes.

And then I tried:

   string fileToAdd = Regex.Replace(pathToFile, @"^[^_]*\\", ""); // - UNC

        string cName = number + "-" + name;

        byte[] bytes = System.IO.File.ReadAllBytes(pathToFile); //Loads all of file, needs full path to file here

        FileCreationInformation newFile = new FileCreationInformation();

        ClientContext context = new ClientContext(url);
        context.RequestTimeout = Int32.MaxValue;

        context.Credentials = new NetworkCredential("userName", "password", "domain");
        List uploadFileLocation = context.Web.Lists.GetByTitle(libraryName);

        newFile.Content = bytes;
        newFile.Content = System.IO.File.ReadAllBytes(pathToFile);

        newFile.Overwrite = true;

        switch (type)
            case "spFolder":
                newFile.Url = url + @"/" + cNumber+ @"/" + Name+ @"/" + fileToAdd;
            case "spDocLibrary":
                newFile.Url = url + @"/" + cNumber + @"/" + fileToAdd;

        Microsoft.SharePoint.Client.File uploadFileToSpFolder = uploadFileLocation.RootFolder.Files.Add(newFile);
        //uploadFileToSpFolder.ListItemAllFields["FileLeafRef"] = "Name of file here";

        context.RequestTimeout = Int32.MaxValue;

Which ends up telling me "The file is too long. This operation is currently limited to supporting files less than 2 gigabytes in size."

I've went through many articles about chunking but have had no luck, any suggestions/tips?

1 Answer 1


If you've not resolved this: Which vesion of .Net are you using? i initially had this working in 4.7.x, but when i moved it to an older project(4.0.0) i started recieving the error you mentioned:

"'FileCreationInformation' does not contain a definition for 'ContentStream'"

I changed my target Framework to somethign a bit more modern(4.5.2), updated packages, and this resolved the 'FileCreationInformation' does not contain a definition for 'ContentStream' error.

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.