Example #1
0
        private void SaveVotes(List <VoteEntrieData> entries)
        {
            VoteData        thePlaylistData = new VoteData(entries.ToArray());
            BinaryFormatter saveFormater    = new BinaryFormatter();
            //Create file
            FileStream saveStream = new FileStream(Application.StartupPath + "/Vote/Vote", FileMode.Create);

            //Write to file
            saveFormater.Serialize(saveStream, thePlaylistData);
            saveStream.Close();
        }
Example #2
0
        private List <VoteEntrieData> LoadVotes()
        {
            //Entries
            List <VoteEntrieData> entries = new List <VoteEntrieData>();

            //Load
            if (File.Exists(Application.StartupPath + "/Vote/Vote"))
            {
                BinaryFormatter loadFormater = new BinaryFormatter();
                //Open file
                FileStream loadStream = new FileStream(Application.StartupPath + "/Vote/Vote", FileMode.Open);

                //Obtain the saved data
                VoteData theLoadedVoteData = loadFormater.Deserialize(loadStream) as VoteData;
                loadStream.Close();

                //Copy the entries
                for (int i = 0; i < theLoadedVoteData.Entries.Length; i++)
                {
                    entries.Add(theLoadedVoteData.Entries[i]);
                }
            }
            return(entries);
        }