Hello:
I am receiving a Binary File in a Request from a application. The
stream which comes to me has the boundary (Something like
"---------------------------39<WBR>*0C0F3E0099" 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.da<WBR>*t"
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(byBuf*fer,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.
I also tried writing the binary content to the disk and then reading it
line by line and writing only the needed content to another file using
streamreader and streamwriter, but i get a wierd error - "Found a low
surrogate char without a preceding high surrogate at index: 620. The
input may not be in this encoding, or may not contain valid Unicode
(UTF-16) characters. Parameter name: chars" - Exception
Does anyone know how to filter binary content? Thanks in advance for
all your help!!
Regards
Sunil Jambekar