Beispiel #1
0
        public void SaveSubmissionsToFile(List <Submission> submissions)
        {
            using (Stream stream = File.Open(_submissionsFileName, FileMode.Create))
            {
                var bformatter = new IndiePortable.Formatter.BinaryFormatter();

                bformatter.Serialize(stream, submissions);
            }
            //using (StreamWriter streamWriter = new StreamWriter(new FileStream(_submissionsFileName, FileMode.Append)))
            //{
            //    foreach (Submission sub in submissions)
            //    {
            //        string save = sub.FirstName + "|" + sub.LastName + "|" + sub.Email + "|" + sub.Phonenumber + "|" + sub.Birthdate + "|" + sub.Password + "|" + sub.LotterySerial + "|" + sub.SubmissionDate;
            //        streamWriter.WriteLine(save);
            //    }
            //}
        }
Beispiel #2
0
        public List <Submission> LoadSubmissionsFromFile()
        {
            List <Submission> submissionList = new List <Submission>();

            using (Stream stream = File.Open(_submissionsFileName, FileMode.Open))
            {
                var bformatter = new IndiePortable.Formatter.BinaryFormatter();

                submissionList = (List <Submission>)bformatter.Deserialize(stream);
            }
            //using (StreamReader streamReader = new StreamReader(_submissionsFileName))
            //{
            //    while ((line = streamReader.ReadLine()) != null)
            //    {
            //        submissionList.Add(line);
            //    }
            //}
            return(submissionList);
        }