@August Asheim Birkeland Thanks for reaching out to Microsoft Q&A.
The maximum size of a MemoryStream object that can be handled by the System.IO.MemoryStream class is determined by the amount of available memory on the system. The maximum size of a MemoryStream object is 2 gigabytes (GB) by default.
Reference docs- https://learn.microsoft.com/en-us/dotnet/api/system.io.memorystream.capacity?view=net-7.0
https://learn.microsoft.com/en-us/dotnet/api/system.int32.maxvalue?view=net-7.0
Please also refer to this thread that discusses a similar issue and a workaround- https://learn.microsoft.com/en-us/answers/questions/630079/how-to-store-2gb-above-size-file-in-file-stream-ta
P.S: You can try also try using filestream instead of memorystream and see if that help you here.
Hope this helps. Please let us know if you have any more questions and we will be glad to assist you further. Thank you!
Remember:
Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.
Want a reminder to come back and check responses? Here is how to subscribe to a notification.