CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jan 2012
    Posts
    6

    Filestream System.OutofmemoryException

    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
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured