Beispiel #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            uint   id   = 0;
            string name = "";

            RoofTable roofs = new RoofTable();

            roofs.Items = new List <RoofItem>();

            DirectoryInfo dir = new DirectoryInfo("Roofs");

            foreach (FileInfo file in dir.GetFiles())
            {
                if (file.Extension == ".bmp")
                {
                    name = Path.GetFileNameWithoutExtension(file.Name);

                    roofs.Items.Add(new RoofItem()
                    {
                        ID       = id,
                        Name     = name,
                        Category = 6,
                        Price    = 0
                    });


                    id++;
                }
            }

            RoofTable.Save("roofs.xml", roofs);
        }
Beispiel #2
0
        public static void Save(string xmlFilePath, RoofTable table)
        {
            XmlSerializer serialize = new XmlSerializer(typeof(RoofTable));



            using (var writer = new StreamWriter(xmlFilePath))
            {
                serialize.Serialize(writer, table);
            }
        }