C#: Serialize to XML

Writing this here so I can find it quickly: –

using System.IO;
using System.Xml.Serialization; 

public class SaveData
    public string title;

XmlSerializer ser = new XmlSerializer(typeof(SaveData));
TextWriter writer = new StreamWriter(Path.Combine(Application.persistentDataPath, "data.xml"));
ser.Serialize(writer, m_data);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: