I need your help: I want to save a zip file at a sql database.
I tried to to the same like saving txt files, but if I want to open the saved file (it was created from a stream)
the zip file is coruppted!
saving zip file as stream
Dim fs As New FileStream(tmpPfad, FileMode.Open, FileAccess.Read)
Dim bytData(fs.Length() - 1) As Byte
fs.Read(bytData, 0, bytData.Length)
fs.Close()
Dim i As Integer
Dim tmpSQLUpdate As New SqlClient.SqlCommand()
tmpSQLUpdate.Parameters.Add(New System.Data.SqlClient.SqlParameter("@FFile", SqlDbType.Image, bytData.Length, ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, bytData))
tmpSQLUpdate.CommandText = "update tblfiles set ffile = @ffile where ID = 1"
open stream as zip file
Dim MyData() As Byte
MyData = Me.OpenRowSelection.Item(0).Cells("File").Value '(Bytestream)
Dim K As Long
K = UBound(MyData)
'Dim tmpPfad As String = "d:\tmp\"
tmpPfad += Me.OpenRowSelection.Item(0).Cells("ID").Value.ToString + "." + me.OpenRowSelection.Item(0).Cells("Ext").Value.ToString
Dim fs As New FileStream(tmpPfad, FileMode.Create, FileAccess.Write)
fs.Write(MyData, 0, K)
fs.Close()
fs = Nothing

Add Reply




MultiQuote


| 


