Results 1 to 3 of 3

Thread: file stream

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    file stream

    Is it possible to use this code to view a BLOB in the db. The file not in my harddrive and I'm having a problem converting a Byte()array to a string?

    Code:
    Dim strFileName As String = ("C:\index.pdf")
    Dim objStream As Stream = File.Open(strFileName, FileMode.Open)
    Dim buffer(objStream.Length) As Byte
    objStream.Read(buffer, 0, objStream.Length)
    objStream.Close()

  2. #2
    Member
    Join Date
    Dec 2002
    Location
    NY, USA
    Posts
    52
    This function will return a string when given a byte array:

    Public Function ByteArrayToString(ByVal bytArray() As Byte) As String
    Dim UTF8 As New UTF8Encoding()
    Return UTF8.GetString(bytArray)
    End Function
    Iouri Boutchkine

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    thanks IOU...I didn't end up needing to convert the Byte array...I used:

    Code:
    Do While objDR.Read = True
                    Dim pdf As String = "bid_package.pdf"
                    Response.Clear()
                    Response.ContentType = "application/octet-stream"
                    Response.AddHeader("Content-Disposition", "attachment;filename=" & Trim(pdf))
                    Response.BinaryWrite(objDR("bid_document"))
                    Response.Flush()
                    Response.End()
                Loop
    but I'm going to save that piece of code..thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width