Exemplo n.º 1
0
        public bool Save()
        {
            try
            {
                BinaryFormatter lFormatter = new BinaryFormatter();
                using (FileStream tStream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write))
                {
                    DatabaseTables lTables = new DatabaseTables
                    {
                        Kunden = Kunden
                    };
                    lFormatter.Serialize(tStream, lTables);
                    tStream.Flush();
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool Load()
        {
            if (!File.Exists(FileName))
            {
                Kunden = new List <Kunde>();
                return(true);
            }

            try
            {
                BinaryFormatter lFormatter = new BinaryFormatter();
                using (FileStream tStream = new FileStream(FileName, FileMode.Open, FileAccess.Read))
                {
                    DatabaseTables lTables = (DatabaseTables)lFormatter.Deserialize(tStream);
                    Kunden = lTables.Kunden;
                }
            }
            catch (Exception e)
            {
                return(false);
            }

            return(true);
        }