From 4cc1f09032d1a9e197320e520a2df92dac5ad812 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 25 Mar 2025 08:35:27 +0100 Subject: [PATCH] Update --- FileReadAndWrite.csproj | 1 + Service/FileService.cs | 11 +++++++-- View/AppDataFilePage.xaml | 5 +++- View/AppDataFilePage.xaml.cs | 6 ++++- View/RawFilePage.xaml.cs | 23 ++---------------- ViewModel/AppDataFilePageVM.cs | 43 ++++++++++++++++++++++++++++++++++ ViewModel/MainViewModel.cs | 2 +- ViewModel/RawFilePageVM.cs | 37 +++++++++++++++++++++++++++++ 8 files changed, 102 insertions(+), 26 deletions(-) create mode 100644 ViewModel/AppDataFilePageVM.cs create mode 100644 ViewModel/RawFilePageVM.cs diff --git a/FileReadAndWrite.csproj b/FileReadAndWrite.csproj index bc7327d..c5741c4 100644 --- a/FileReadAndWrite.csproj +++ b/FileReadAndWrite.csproj @@ -57,6 +57,7 @@ + diff --git a/Service/FileService.cs b/Service/FileService.cs index 4b170da..970bcd8 100644 --- a/Service/FileService.cs +++ b/Service/FileService.cs @@ -7,11 +7,18 @@ public class FileService public FileService() { // Plik, który będzie przechowywał zawartość naszej aplikacji - _filePath = Path.Combine(FileSystem.AppDataDirectory, "data.txt"); + _filePath = Path.Combine(FileSystem.AppDataDirectory, "tekst.txt"); } - public async Task SaveToFile(){ + public async Task SaveToFile(string content){ + await File.WriteAllTextAsync(_filePath, content); + } + public async Task LoadFromFile(){ + if (!File.Exists(_filePath)) + return "Nie znaleziono pliku!"; + + return await File.ReadAllTextAsync(_filePath); } public async Task LoadAsset(string asset){ diff --git a/View/AppDataFilePage.xaml b/View/AppDataFilePage.xaml index d21f065..1fa9f4a 100644 --- a/View/AppDataFilePage.xaml +++ b/View/AppDataFilePage.xaml @@ -8,7 +8,10 @@ - +