Exemplo n.º 1
0
        //  Aggiorna il file XML che usa come DB
        public static void WriteFile(CDataBlock db)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(CDataBlock));
            Stream        stream        = (Stream) new FileStream(db.DBName + ".xml", FileMode.Create, FileAccess.Write, FileShare.Read);

            xmlSerializer.Serialize(stream, (object)db);
            stream.Close();
        }
Exemplo n.º 2
0
        //  Legge il file XML che usa come DB
        public static void ReadFile(ref CDataBlock db)
        {
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(CDataBlock));

            try
            {
                Stream stream = (Stream) new FileStream(db.DBName + ".xml", FileMode.Open, FileAccess.Read, FileShare.Write);
                db = (CDataBlock)xmlSerializer.Deserialize(stream);
                stream.Close();
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.Message);
            }
        }