Function LoadSoapData(ByVal path As String) As Object Dim fs As FileStream = New FileStream(path, FileMode.Open) Dim sf As New SoapFormatter(Nothing, _ New StreamingContext(StreamingContextStates.File))
LoadSoapData = sf.Deserialize(fs) fs.Close() End Function
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 |