コード例 #1
0
        private void btnUptade_Click(object sender, EventArgs e)
        {
            ReminderFilePath = @"data/" + MainWindow.username + "Reminder.csv";
            string type;

            if (rdobtnMeeting.Checked)
            {
                type = rdobtnMeeting.Text;
            }
            else
            {
                type = rdobtnTask.Text;
            }
            try
            {
                MeetingTaskReminder reminder = new MeetingTaskReminder(txtboxDate.Text, mtxtboxTime.Text, txtSummary.Text,
                                                                       txtDescription.Text, type, MainWindow.username);
                var file = new List <string>(System.IO.File.ReadAllLines(ReminderFilePath));
                file.Insert(lstReminder.FocusedItem.Index, reminder.ReminderToCsv());
                file.RemoveAt(lstReminder.FocusedItem.Index + 1);
                System.IO.File.WriteAllLines(ReminderFilePath, file.ToArray());
                btnList_Click(sender, e);
            }
            catch (Exception)
            {
                MessageBox.Show("Select a reminder for updating.");
            }
        }
コード例 #2
0
 public static void SaveCsv(MeetingTaskReminder reminder, string csvPath)
 {
     try
     {
         using (StreamWriter writer = File.AppendText(csvPath))
         {
             writer.WriteLine(reminder.ReminderToCsv());
         }
     }
     catch (Exception)
     {
         Console.WriteLine("The file could not be write:");
     }
 }