private void mathSpeed_FormClosing(object sender, FormClosingEventArgs e) { recClass = new record(); recClass.userRecord = recordcount; using (FileStream fs = new FileStream("record.cfg", FileMode.Create)) { IFormatter ft = new BinaryFormatter(); ft.Serialize(fs, recClass); } }
private void mathSpeed_Load(object sender, EventArgs e) { timeLimit = 6; count = timeLimit; upper = 10; lower = 1; winCount = 0; tbAnswer.Enabled = false; if (File.Exists("record.cfg")) { using (FileStream fs = new FileStream("record.cfg", FileMode.Open)) { IFormatter ft = new BinaryFormatter(); recClass = ft.Deserialize(fs) as record; recordcount = recClass.userRecord; } } lblRecord.Text = recordcount.ToString(); }