Results 1 to 3 of 3

Thread: [Resolved] ReadAllBytes fails reading 1GB file

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    Resolved [Resolved] ReadAllBytes fails reading 1GB file

    When I try to create a byte array to read a file that's 1GB in size, I get System.OutOfMemoryException. I assume this means there isn't enough system memory to allocate an array of bytes this large.

    Is there some other way I can read this file, possibly in chunks, to deal with it?

    Code:
    System.IO.FileInfo fi = new System.IO.FileInfo(txtRead.Text);
    byte[] bt;
    
    try
    {
        bt = new byte[fi.Length];
        bt = System.IO.File.ReadAllBytes(txtRead.Text);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
    Last edited by wey97; Oct 20th, 2006 at 07:33 AM.

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