I was following the example found here on serializing chunks of a large file. Somehow being new to serialization I am now lost as to what parameters to pass to my Serialize method. I have shelved the approach I was using yesterday because of the OOM exception. Will appreciate your help.
Public Shared Sub ReadAndProcessLargeFile(theFilename As String, ByVal obj As LocalDBObject, Optional whereToStartReading As Long = 0)
Dim bf As New BinaryFormatter() ' Create a binary formatter for this stream.
Using fileStram As New FileStream(theFilename, FileMode.Open, FileAccess.Read)
Dim buffer As Byte() = New Byte(fileStram.Length - 1) {}
fileStram.Seek(whereToStartReading, SeekOrigin.Begin)
Dim bytesRead As Integer = fileStram.Read(buffer, 0, buffer.Length)
While bytesRead > 0
bytesRead = fileStram.Read(buffer, 0, buffer.Length - 1)
'It is here where I am now lost. What parameters do I supply to my Serialize method below
bf.Serialize()
End While
End Using
End Sub
Hmmm, that code is just not serializing anything, to serialize you should do this:
Public Shared Sub Serialize(theFilename As String, ByVal obj As LocalDBObject)
Dim bf As New BinaryFormatter() ' Create a binary formatter for this stream.
Using fileStram As File.Create(theFilename)
bf.Serialize(fileStram, obj);
End Using
End Sub
But I suspect this is not what you want, unless you explain a bit better your question is really hard to understand what you want to achieve.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.