You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

27 lines
603 B

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace SelfHelpClient.Utils
{
public static class XmlUtil
{
public static T DeserializeFromFile<T>(string fileName)
where T : new()
{
if (!File.Exists(fileName))
return new T();
using (var reader = new StreamReader(fileName))
{
var xs = new XmlSerializer(typeof(T));
object obj = xs.Deserialize(reader);
reader.Close();
return (T)obj;
}
}
}
}