Read/Write XML trouble with VB2005
Hi,
I need to populate treeview from XML file. I found this code written in VB2003 whitch doesn't work in VB2005. There is an error "InvaliOperationException" in line "Dim treeData As TreeViewData = CType(ser.Deserialize(reader), TreeViewData)"
VB Code:
Public Shared Sub LoadTreeViewData(ByVal treeView As TreeView, ByVal path As String)
'Create as serializer and get the file to deserialize
Dim ser As New System.Xml.Serialization.XmlSerializer(GetType(TreeViewData))
Dim file As New System.IO.FileStream(path, IO.FileMode.Open)
Dim reader As New System.Xml.XmlTextReader(file)
'Deserialize the file and populate the treeview
Dim treeData As TreeViewData = CType(ser.Deserialize(reader), TreeViewData)
treeData.PopulateTree(treeView)
'Tidy up
reader.Close()
file.Close()
file = Nothing
End Sub
Thanks in advance.