Reading Binary Content from a File and Filtering it

Discussion in 'ASP .Net' started by Neo, Jun 29, 2005.

  1. Neo

    Neo Guest

    Hello:

    I am receiving a Binary File in a Request from a application. The
    stream which comes to me has the boundary (Something like
    "---------------------------390C0F3E0099" without the quotes), and also
    some more text like this and file name (e.g. "Content-Disposition:
    form-data; name="upload_file"; filename="C:\testing\myfile.dat"
    Content-Type: application/octet-stream")

    The binary content starts after "application/octet-stream".

    The end of the file is also a boundary.

    I need to filter this content and only write the binary content to the
    disk.

    I know the boundary string from the Request Headers and also the file
    size. I am reading the request into a byte array using the following
    code -

    <code>
    int iLength = (int) Request.InputStream.Length;
    byte[] byBuffer = new byte[iLength];
    Request.InputStream.Read(byBuffer,0,iLength);
    </code>

    Then i am using a filestream object to write the buffer to disk.

    I dont know how to filter/replace the binary content. I tried to
    convert it into a String object, but the file sizes are more than 2 MB,
    and i dont want the string object to hold os much data.

    Can someone please suggest any method of replacing some text in a
    Binary content. I want to remove the boundary text from the stream.

    Regards

    Sunil Jambekar
    Neo, Jun 29, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hazz
    Replies:
    6
    Views:
    49,419
    SkyUCHC
    Jun 9, 2010
  2. Paul Paterson
    Replies:
    0
    Views:
    382
    Paul Paterson
    Aug 30, 2003
  3. John J. Lee
    Replies:
    2
    Views:
    323
    John J. Lee
    Aug 30, 2003
  4. Ed Stoner
    Replies:
    1
    Views:
    366
    John J. Lee
    Sep 2, 2003
  5. Replies:
    7
    Views:
    331
Loading...

Share This Page