All pastes #485136 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-05-12 21:46 UTC
rendered paste body
//The class that contains the data
public class Configdata {
string m_data = "0"; // you dont need to initialize it it'll just be omitted from the saving of the file if null..

public string data
  {
    get { return m_data; }
    set { m_data= value; }
  }
}
-----------------------------------------------
//For loading stuff
 System.IO.StreamReader istream = new System.IO.StreamReader("test.xml");
 XmlSerializer serializer = new XmlSerializer(typeof(Configdata));
 ConfigData.UserConfig config = (ConfigData.UserConfig)serializer.Deserialize(istream);
-----------------------------------------------
//For saving stuff
 ConfigData config = new ConfigData.UserConfig();
 System.IO.StreamWriter ostream = new System.IO.StreamWriter("test.xml");
 XmlSerializer serializer = new XmlSerializer(typeof(ConfigData.UserConfig));
 serializer.Serialize(ostream, config);
----------------------------------------------