G
Guest
Hi all,
I have problem in using the filestream .
below is my sample code:
Dim s2 As New FileStream("C:Save\Grab.xls", FileMode.Open,
FileAccess.Read, FileShare.Read)
s2.Lock(0, 0)
Dim sFileType As String
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(s2.Length)
Dim NewAttachment As New WebTest.InfoDataAccessObject
With NewAttachment
.lAttachment_ID = CLng("1")
.sFileName = "Grab.xls"
.iFileSize = s2.Length
.bFileContent = bytContent
.sFileType = "application/vnd.ms-excel"
.UpdateNonExpiredInfoWithUpload()
End With
s2.Unlock(0, 0)
I sucessfully update the data into sql database in binary format.
but when i open it by using response property, the file is no longer
recognized format by excel.
Here is the way to read:
Response.ContentType = dr("FILE_TYPE").ToString
Response.OutputStream.Write(CType(dr("FILE_DATA"), Byte()), 0,
CInt(dr"FILE_SIZE")))
Response.AddHeader("Content-Disposition", "attachment;filename=" +
dr("FILE_NAME").ToString())
The excel content turn to all html code in it. How to solve it? Any ideas?
thank you.
Best regards,
Ocurnos
I have problem in using the filestream .
below is my sample code:
Dim s2 As New FileStream("C:Save\Grab.xls", FileMode.Open,
FileAccess.Read, FileShare.Read)
s2.Lock(0, 0)
Dim sFileType As String
Dim sFileName As String, i As Integer
Dim bytContent As Byte()
ReDim bytContent(s2.Length)
Dim NewAttachment As New WebTest.InfoDataAccessObject
With NewAttachment
.lAttachment_ID = CLng("1")
.sFileName = "Grab.xls"
.iFileSize = s2.Length
.bFileContent = bytContent
.sFileType = "application/vnd.ms-excel"
.UpdateNonExpiredInfoWithUpload()
End With
s2.Unlock(0, 0)
I sucessfully update the data into sql database in binary format.
but when i open it by using response property, the file is no longer
recognized format by excel.
Here is the way to read:
Response.ContentType = dr("FILE_TYPE").ToString
Response.OutputStream.Write(CType(dr("FILE_DATA"), Byte()), 0,
CInt(dr"FILE_SIZE")))
Response.AddHeader("Content-Disposition", "attachment;filename=" +
dr("FILE_NAME").ToString())
The excel content turn to all html code in it. How to solve it? Any ideas?
thank you.
Best regards,
Ocurnos