You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.0 KiB
39 lines
1.0 KiB
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<Note> Notes { get; set; } = new ObservableCollection<Note>();
|
|
|
|
public AllNotes()
|
|
{
|
|
LoadNotes();
|
|
}
|
|
public void LoadNotes()
|
|
{
|
|
Notes.Clear();
|
|
|
|
string appDataPath = FileSystem.AppDataDirectory;
|
|
IEnumerable<Note> 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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|