Click to See Complete Forum and Search --> : Response.BinaryWrite() question


thechasboi
08-06-2007, 11:51 AM
I have these image files not large at all that I would like to send to the browser as inary data. The thing is they are not in a db table they are hard file on the server. So I would like to know a way to change the hard file to a binary form the send it to the browser via the Response.BinaryWrite() function. Thanks for the reply.

TheBearMay
08-06-2007, 01:27 PM
Should be able to read them in using the BinaryReader....

thechasboi
08-07-2007, 08:03 AM
This is the example I found on the ms site


Dim MyFileStream As FileStream
Dim FileSize As Long

MyFileStream = New FileStream("sometext.txt", FileMode.Open)
FileSize = MyFileStream.Length

Dim Buffer(CInt(FileSize)) As Byte
MyFileStream.Read(Buffer, 0, CInt(FileSize))
MyFileStream.Close()

Response.Write("<b>File Contents: </b>")
Response.BinaryWrite(Buffer)


There are a few problems with this because I insert this into an asp page and I get errors. I have done plenty of vbscript but do not know how to translate this to vbscript. I am guessing this is not going to be much at least but lack the knowledge to do so.

Thanks for the reply.