Filestreaming System.OutofMemoryException - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Filestreaming System.OutofMemoryException

sharoncsharonc Posts: 11Member
Hi,
I am getting an System.OutofmemoryException when using Filestream to load zip file. the file is 521MB. My code is:

//Insert using Filestream, file into SQL Server Table
private void btnInsert_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDlg = new OpenFileDialog();
openFileDlg.InitialDirectory = Directory.GetCurrentDirectory();
if (openFileDlg.ShowDialog() == DialogResult.OK)
{
FileInfo fi = new FileInfo(openFileDlg.FileName);
FileStream fs = new FileStream(fi.FullName, FileMode.Open, FileAccess.Read);
BinaryReader rdr = new BinaryReader(fs);
byte[] fileData = rdr.ReadBytes((int)fs.Length);
rdr.Close();
fs.Close();

My program dies on this line: byte[] fileData = rdr.ReadBytes((int)fs.Length);

i have also attached the detail for the System.OutofMemoryException.

I am runing this on a Windows 7, 64bit machine.

thanks for your help.

Sharon
Sign In or Register to comment.