Deepika Chaudhary

Deepika Chaudhary

  • 1.6k
  • 136
  • 97.8k

Problem with byte array with more size

Aug 2 2011 7:51 AM
Hi all,

i want to upload file using web service..
For that i have written this code in client application.

I have a problem with more no. of bytes. like for 1 gb(1073741823)

I am not able to create the byte array with this size. i want to upload maximum 2 gb file.


byte[] data = new byte[1073741823];

Getting following error at run time.
Exception of type 'System.OutOfMemoryException' was thrown.







System.IO.FileStream stream = new System.IO.FileStream(fileInfo.FullName, System.IO.FileMode.Open, System.IO.FileAccess.Read)

BinaryReader br = new BinaryReader(stream);
long numBytes = fileInfo.Length;//here fileinfo.length value is 1073741823
data = br.ReadBytes((
I am again getting the same exception error in the above line.
How to solve this problem..how can this work till 2 gb size(2147483647 bytes)

Please help..


int)numBytes);

Answers (10)