Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Newtonsoft.Json;
- using RepClasses;
- namespace MainForm
- {
- public partial class Form1 : Form
- {
- static public List<Student> students = new List<Student>();
- public Form1()
- {
- InitializeComponent();
- }
- private void AddStudent_Click(object sender, EventArgs e)
- {
- var addWindow = new Form2();
- addWindow.Show();
- }
- private void start_Click(object sender, EventArgs e)
- {
- students.Clear();
- if (File.Exists(@"C:\Users\thisp\Desktop\Tutoring\RepsProg\studentsData.txt"))
- {
- List<Student> list = JsonConvert.DeserializeObject
- <List<Student>>(File.ReadAllText
- (@"C:\Users\thisp\Desktop\Tutoring\RepsProg\studentsData.txt"));
- foreach (Student jo in list)
- {
- students.Add(jo);
- }
- }
- else
- File.Create(@"C:\Users\thisp\Desktop\Tutoring\RepsProg\studentsData.txt");
- }
- private void finish_Click(object sender, EventArgs e)
- {
- List<Student> list = new List<Student>();
- foreach (Student jo in students)
- {
- list.Add(jo);
- }
- string json = JsonConvert.SerializeObject(list, Formatting.Indented);
- File.WriteAllText
- (@"C:\Users\thisp\Desktop\Tutoring\RepsProg\studentsData.txt", json);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment