Binary Serialization
The following example shows how you can serialize a typed collection of strings into a file on disk using the BinaryFormatter
class:
Dim stringSeries As New List(Of String) From {"Serialization", "demo", "with VB"}Dim targetFile As New _ FileStream("C:\temp\SerializedData.dat", FileMode.Create)Dim formatter As New BinaryFormatterformatter.Serialize(targetFile, stringSeries)targetFile.Close()formatter = Nothing
Note
The previous code example requires Imports System.IO
and Imports System.Runtime.Serialization.Formatters.Binary
directives.
The code creates a new file named SerializedData.dat
and puts the result of the binary serialization ...
Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.