Converting Byte array to filestream

Posted by Naveenmanam under ASP.NET on 4/30/2010 | Views : 6048 | Status : [Member] | Replies : 2
I have a file saved in sql server as "byte[]" byte array.

Now is there any way to convert byte[] to FileStream directly .

NaveenKumar


Responses

Posted by: Pavanandey on: 4/30/2010 [Member] Bronze

Up
0
Down
read the bytes into datareader

If (drfile.Read()) Then

Dim fileSize As Integer
Dim contentType As String
Dim fileData() As Byte

fileSize = CInt(drfile(0))
contentType = drfile.GetString(2)
ReDim fileData(fileSize)
drfile.GetBytes(1, 0, fileData, 0, fileSize) 'Repeatedly reads until EOF
Response.Clear()
Response.AppendHeader("Content-Disposition", "attachment; filename=" & fname)
ReDim fileData(fileSize)
drfile.GetBytes(1, 0, fileData, 0, fileSize) 'Repeatedly reads until EOF
Response.Clear() 'clears resposne to nil

Response.ContentType = contentType
Response.OutputStream.Write(fileData, 0, fileData.Length)
If contentType = "text/plain" Or contentType = "application/vnd.ms-excel" Then
Response.End()
End If

Thanks
Pavan Kumar
Mark Answer if this fits the need

Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenmanam on: 4/30/2010 [Member] Starter

Up
0
Down
thank you pavan

NaveenKumar

Naveenmanam, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response