Code snippet to serialize your garage to file could look like:
var garage = new theGarage();
// TODO init your garage..
XmlSerializer xs = new XmlSerializer(typeof(theGarage));
TextWriter tw = new StreamWriter(@"c:\temp\garage.xml");
xs.Serialize(tw, garage);
And code to load garage from file:
using(var sr = new StreamReader(@"c:\temp\garage.xml"))
{
garage = (theGarage)xs.Deserialize(sr);
}
SOURCE : https://stackoverflow.com/questions/13266496/easily-write-a-whole-class-instance-to-xml-file-and-read-back-in
'C#(CSharp) > Etc' 카테고리의 다른 글
Single Global Mutex (0) | 2019.06.25 |
---|---|
IOException: The process cannot access the file 'file path' because it is being used by another process (0) | 2018.06.23 |
C# memory cache logic (0) | 2018.05.31 |
Write exception log in File. (0) | 2018.05.29 |
c# memory cache (0) | 2018.05.26 |