For some reason my previous question was considered too vague. So let me be more specific.
I have a 2 dimensional array of type single. I want to serialize it to save in an Access database.
The suggestion was to save it as a Memo field which is fine. I want to later read the Memo field and deserialize it to retrieve the original array. I have searched extensively on the web and here and can not find the answer. I believe I am serializing the array correctly but do not know how to deserialize it.
This code appears to work for serializing but I can not figure out how to deserialize:
Dim f As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
Dim ms As New MemoryStream
f.Serialize(ms, arLHS)
Dim byArr As Byte() = ms.ToArray
I then save byArr to the Memo field.
Please provide sample code.
You can deserialize it via base64 converter:
Dim str_b64 As String = Convert.ToBase64String(byArr)
Dim ms2 As New MemoryStream(Convert.FromBase64String(str_b64))
Dim intArr2(,) As Int32 = f.Deserialize(ms2)
This may look somewhat awkward, but it works - tested in a console app in VS 2010.
Credit goes here. Through this link, you can also find the full version of the code to play with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With