Exemple #1
0
    public void saveData()
    {
        BinaryFormatter binaryFormatter = new BinaryFormatter();
        FileStream      file            = File.Create(pathFile);
        dataToSave      data            = new dataToSave();

        data.maxScore = maxScore;
        binaryFormatter.Serialize(file, data);
        file.Close();
    }
Exemple #2
0
 void loadData()
 {
     if (File.Exists(pathFile))
     {
         BinaryFormatter binaryFormatter = new BinaryFormatter();
         FileStream      file            = File.Open(pathFile, FileMode.Open);
         dataToSave      data            = (dataToSave)binaryFormatter.Deserialize(file);
         maxScore = data.maxScore;
         file.Close();
     }
     else
     {
         maxScore = 0;
     }
 }