Object to Xml File
//Required libraries
using System.Xml.Serialization;
using System.IO;
public static void ObjectToXMLFile(object T, string FilePath)
{
string xmlData = string.Empty;
var sr = new XmlSerializer(T.GetType());
using (var file = new StreamWriter(FilePath))
{
sr.Serialize(file, T);
}
}
using System.Xml.Serialization;
using System.IO;
public static void ObjectToXMLFile(object T, string FilePath)
{
string xmlData = string.Empty;
var sr = new XmlSerializer(T.GetType());
using (var file = new StreamWriter(FilePath))
{
sr.Serialize(file, T);
}
}
No comments