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);
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 running this on a Windows 7, 64bit machine.
thanks for your help.
Re: Filestreaming System.OutofMemoryException
As I mentioned I have a machine that has 8 GB of memory. I had to shut down my machine to take it home last night.
When I tried to load the file again today it loaded with no problem. Normally I will only be loading one file at a
time, but in this case I was testing my Development database and was loading 28 files one right after the other.
|All times are GMT +5.5. The time now is 17:02.|