Ejemplo n.º 1
0
 public void AddNote(string text)
 {
     var noteItem = new NoteItem(text);
     this.NoteItems.Add(noteItem);
     //StreamWriter writer = new StreamWriter("todo-items.txt", true);
     //using (writer)
     //{
     //    writer.WriteLine(text);
     //}
 }
Ejemplo n.º 2
0
 private void RemoveFromFile(NoteItem noteItem)
 {
     StringBuilder output = new StringBuilder();
     StreamReader file = new StreamReader("todo-items.txt");
     using (file)
     {
         string line = file.ReadLine();
         while (line != null)
         {
             if (line != noteItem.Serialize())
             {
                 output.AppendLine(line);
             }
             line = file.ReadLine();
         }
     }
     file.Close();
     StreamWriter result = new StreamWriter("todo-list.txt", false);
     using (result)
     {
         result.Write(output.ToString());
     }
 }