Click here to Skip to main content
15,616,520 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am converting large file into byte of array but it showing OutofMemory Exception.

The File size is 750 MB.

My OS :- 32bit
RAM :- 4 GB
Framework :- 4.5
byte[] encryptedData = new byte[832615276];

It showing Error.

Any alternate solution so please let me know.

Errors comes when initialize the byte array. Is there any size limit ?


What I have tried:

byte[] encryptedData = new byte[832615276];
Updated 26-Aug-16 3:45am

byte[] data = File.ReadAllBytes(pathToFile);

If that gives you problems, then it may be that you need to check what else your code is doing, as an array can be up to 2GB. 750MB should be no problem at all.

If you can't load it as a complete item, then consider loading it as a FileStream - you can read that in "chunks" and most decryption methods have a method accepting streams.
Share this answer
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900