Serialize objects into xml file in .net
Imports System.IO
Imports System.Xml.Serialization
Public Class Serializer
Public Shared Sub SerializeTaskToXMLFile(ByVal [Object] As Object, ByVal Path As String)
Dim XmlSerializer As New XmlSerializer(GetType(Task))
Dim File As New StreamWriter(Path)
XmlSerializer.Serialize(File, [Object])
File.Close()
End Sub
Public Shared Function DeserializeTaskFromXMLFile(ByVal Path As String) As Task
Dim XmlSerializer As New XmlSerializer(GetType(Task))
Dim File As New StreamReader(Path)
Dim [Object] As Object = XmlSerializer.Deserialize(File)
File.Close()
Return CType([Object], Task)
End Function
End Class
Imports System.Xml.Serialization
Public Class Serializer
Public Shared Sub SerializeTaskToXMLFile(ByVal [Object] As Object, ByVal Path As String)
Dim XmlSerializer As New XmlSerializer(GetType(Task))
Dim File As New StreamWriter(Path)
XmlSerializer.Serialize(File, [Object])
File.Close()
End Sub
Public Shared Function DeserializeTaskFromXMLFile(ByVal Path As String) As Task
Dim XmlSerializer As New XmlSerializer(GetType(Task))
Dim File As New StreamReader(Path)
Dim [Object] As Object = XmlSerializer.Deserialize(File)
File.Close()
Return CType([Object], Task)
End Function
End Class