2011-03-31

Feltalaltam a spanyol viaszt

if somebdy makes me think
then I think
else :D

XML "database" with C#

1. Step: create class structure for dataset (I'll call it ADS)
2. Step: ADS ads = new ADS(); then init ads
3. Step: serialize

TextWriter writer = new StreamWriter("test.xml");
XmlSerializer serializer = new XmlSerializer(typeof(ADS));
serializer.Serialize(writer, ads);
writer.Close();

4. Step: delete serialize call
5. Step: start using the xml, read all your data in 5 (five) lines

XmlSerializer serializer = new XmlSerializer(typeof(ADS));
FileStream fs = new FileStream("test.xml", FileMode.Open);
XmlReader reader = new XmlTextReader(fs);
ads = (ADS)serializer.Deserialize(reader);
fs.Close();

PS. Don't forget about the try-catch(s), but throw all your oldschool ideas

Special thanks to HUPU

4 comments:

Betond said...

Kevered a két blogod?

Vera Linn said...

nem, ide az erzelmeimet irom ... ez azt jelenti, hogy most eppen boldog vagyok. de tul is kiteszem.
PS. jo hamar lereagaltad

Betond said...

hurra

Egyszer elarulod, min mulik a boldogsag?

Vera Linn said...

Gondolom a pillanaton.