Thread: Binary Reader Buffer size

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2011
    Posts
    5

    Binary Reader Buffer size

    Hello,

    I woud like to read a very big binary file in C#. Say, 256 Mega Bytes of data. Actually I should read from one big 256Mbytes file and append to another file.
    How do I append to my original file?
    can i use some thing like this?

    Code:
    public static byte[] ReadFully (Stream stream)
    {
    byte[] buffer = new byte[268435456];
    using (MemoryStream ms = new MemoryStream())
    {
    while (true)
    {
    int read = stream.Read (buffer, 0, buffer.Length);
    if (read <= 0)
    return ms.ToArray();
    ms.Write (buffer, 0, read);
    }
    }
    }
    any help, suggestions is appreciated.


    Thanks,
    Last edited by krischad; 09-28-2011 at 12:17 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Buffer size question.
    By Swerve in forum C++ Programming
    Replies: 6
    Last Post: 11-07-2009, 08:45 AM
  2. size of buffer
    By silentintek in forum C Programming
    Replies: 10
    Last Post: 10-29-2008, 07:21 PM
  3. Get file size when in buffer
    By Siphon in forum C++ Programming
    Replies: 10
    Last Post: 04-10-2008, 10:52 AM
  4. getchar buffer size
    By oncemyway in forum C Programming
    Replies: 3
    Last Post: 08-02-2005, 12:49 AM
  5. Sockets and buffer size
    By Joe Monti in forum Linux Programming
    Replies: 1
    Last Post: 04-04-2003, 09:44 AM

Tags for this Thread