Sub SaveSoapData(ByVal path As String, ByVal o As Object) Dim fs As FileStream = New FileStream(path, FileMode.Create) Dim sf As New SoapFormatter(Nothing, _ New StreamingContext(StreamingContextStates.File)) sf.Serialize(fs, o) fs.Close() End Sub
Sub TestSoapSerialization() Dim ht As New Hashtable() ht.Add("One", 1) ht.Add("Two", 2) ht.Add("Three", 3)
SaveSoapData("c:\hashtbl.xml", ht)
Dim ht2 As Hashtable ht2 = CType(LoadSoapData("c:\hashtbl.xml"), Hashtable)
Dim de As DictionaryEntry For Each de In ht2 Console.WriteLine("Key=" & de.Key.ToString & " Value=" & _ de.Value.ToString) Next End Sub |