using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NotesNet8.Models { internal class AllNotes { public ObservableCollection Notes { get; set; } = new ObservableCollection(); public AllNotes() { LoadNotes(); } public void LoadNotes() { Notes.Clear(); string appDataPath = FileSystem.AppDataDirectory; IEnumerable notes = Directory .EnumerateFiles(appDataPath, "*.notes.txt") .Select(filename => new Note() { Filename = filename, Text = File.ReadAllText(filename), Date = File.GetCreationTime(filename) }) .OrderBy(note => note.Date); foreach (Note note in notes) { Notes.Add(note); } } } }