Imports System.IO Imports System.Runtime.Serialization.Formatters Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim HashT As New Hashtable Dim XMLfrm As New Soap.SoapFormatter HashT.Add("Roxy", "Tom") HashT.Add("Betty", "Frank") Dim t As New Trees t.Name = "Oak" Dim s As Single = 1.552255 Dim fs As New FileStream("c:\test.txt", FileMode.Create, FileAccess.Write) XMLfrm.Serialize(fs, HashT) XMLfrm.Serialize(fs, t) XMLfrm.Serialize(fs, s) fs.Close() deserializeIt() End Sub Sub deserializeIt() Dim HashT As Hashtable Dim T As Trees Dim s As Single Dim XMLfrm As New Soap.SoapFormatter Dim fs As New FileStream("c:\test.txt", FileMode.Open) HashT = XMLfrm.Deserialize(fs) T = XMLfrm.Deserialize(fs) s = XMLfrm.Deserialize(fs) fs.Close() Dim de As DictionaryEntry, s1 As String For Each de In HashT s1 &= de.Key & ", " & de.Value & " ... " Next MsgBox(s1 & "...." & T.Name & " " & s) End Sub End Class <Serializable()> Public Class Trees Private _Name As String Private _Color As String Private _Circumference As Integer Private _height As Integer Public Property Name() As String Get Return _Name End Get Set(ByVal Value As String) _Name = Value End Set End Property Public Property Color() As String Get Return _Color End Get Set(ByVal Value As String) _Color = Value End Set End Property Public Property Circumference() As Integer Get Return _Circumference End Get Set(ByVal Value As Integer) _Circumference = Value End Set End Property Public Property height() As Integer Get Return _height End Get Set(ByVal Value As Integer) _height = Value End Set End Property End Class |