June 2002
Intermediate to advanced
816 pages
28h 12m
English
BinaryWrite
Response.BinaryWrite(ByVal buffer( ) As Byte)
Allows writing of binary content to the output stream. No modification of the output is performed before sending the binary content to the client.
buffer( )
A Byte array containing the binary data to be written to the output stream.
Here is an example of BinaryWrite:
Sub Page_Load( )
Dim ImageStream As New FileStream(MapPath("aspnetian.jpg"), _
FileMode.Open, FileAccess.Read)
Dim ImageBytes(ImageStream.Length) As Byte
ImageStream.Read(ImageBytes, 0, ImageStream.Length)
ImageStream.Close( )
Response.ContentType = "image/bmp"
Response.BinaryWrite(ImageBytes)
Response.End( )
End SubThis method is especially useful for writing binary content retrieved from a database to the browser. When writing image or other nontext data to the browser, you should set the Response.ContentType property to the appropriate MIME type for the image type being sent (such as “image/jpg”).
Read now
Unlock full access