0

I am trying move files from one site collection to another. Following code works for smaller files but not for large files due to memory exceptions:

if (item.FileSystemObjectType == FileSystemObjectType.File)
{
    var fileName = item["FileLeafRef"] as string;
    var fileSize = item["File_x0020_Size"];


    item.Context.Load(item.File);

    using (var stream = item.File.OpenBinaryStream().Value)
    { 
        item.Context.ExecuteQueryWithIncrementalRetry(3, logger);

        var fi = new FileCreationInformation();
        fi.ContentStream = stream;
        fi.Url = fileName;
        fi.Overwrite = true;
        folder.Files.Add(fi);
        destLibrary.Context.ExecuteQueryWithIncrementalRetry(3, logger);
    }
}

Is there anyway to to the same in batches? Notice SaveBinary etc cannot be used with modern authentication.

2

1 Answer 1

0

This one solves the problem:

https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/mt796381(v%3Doffice.15)

Your Answer

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

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