Out of Memory reading large byte array

Sep 30 2009 7:59 AM
I'm fairly new to C# and am perplexed. Executing the following against a file of 641,763,107 bytes, I get an out-of-memory exception. FileStream dFile = new FileStream(iFile, FileMode.Open, FileAccess.Read); BinaryReader binReader = new BinaryReader(dFile); int iLgth = (int)dFile.Length; byte[] dBytes = new byte[iLgth]; dBytes = binReader.ReadBytes(iLgth); binReader.Close(); dFile = null; At the time of execution, the system has 1 1/2gig of memory available. Can anyone help me or explain this error? Dennis

Answers (3)