public static void Save(PersistData data) { var fileName = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData), "SendSheetsViaMail.json"); var jsonValue = JsonConvert.SerializeObject(data); File.WriteAllText(fileName, jsonValue); }
public static PersistData Load() { var fileName = Path.Combine(Environment.GetFolderPath( Environment.SpecialFolder.ApplicationData), "SendSheetsViaMail.json"); if (File.Exists(fileName)) { string jsonValue = File.ReadAllText(fileName); PersistData deserializedData = JsonConvert.DeserializeObject <PersistData>(jsonValue); return(deserializedData); } else { return(null); } }
private void CSVInput_Load(object sender, EventArgs e) { PersistData data = PersistData.Load(); if (data != null) { txtBody.Text = data.MailBody; dt = data.CSVConfig; txtSubject.Text = data.MailTitle; } else { dt.Clear(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("Department"), new DataColumn("Slides"), new DataColumn("E-Mails") }); } BindingSource SBind = new BindingSource(); SBind.DataSource = dt; grdData.Columns.Clear(); grdData.DataSource = SBind; }
private void btnSave_Click(object sender, EventArgs e) { PersistData.Save(new PersistData { MailTitle = txtSubject.Text, MailBody = txtBody.Text, CSVConfig = dt }); }