Exemplo n.º 1
0
        public static bool Load(string path, ref List <string> outBinaryStringArray)
        {
            //Load
            if (File.Exists(path))
            {
                BinaryFormatter loadFormater = new BinaryFormatter();
                //Open file
                FileStream loadStream = new FileStream(path, FileMode.Open);

                //Obtain the saved data
                BinaryStringArray binaryStringArrayData = loadFormater.Deserialize(loadStream) as BinaryStringArray;
                loadStream.Close();

                //Copy the entries
                if (binaryStringArrayData != null)
                {
                    List <string> entries = new List <string>();
                    for (int i = 0; i < binaryStringArrayData.StringArray.Length; i++)
                    {
                        entries.Add(binaryStringArrayData.StringArray[i]);
                    }
                    outBinaryStringArray = entries;
                    return(true);
                }
            }
            //If loaded wrong file or file does not exist
            return(false);
        }
Exemplo n.º 2
0
        public static void Save(string path, List <string> Entries)
        {
            BinaryStringArray binaryStringArrayData = new BinaryStringArray(Entries.ToArray());
            BinaryFormatter   saveFormater          = new BinaryFormatter();
            //Create file
            FileStream saveStream = new FileStream(path, FileMode.Create);

            //Write to file
            saveFormater.Serialize(saveStream, binaryStringArrayData);
            saveStream.Close();
        }