namespace MauiApp1 { public class FileSystemService : IFileSystemService { public string GetRootPath() { #if ANDROID || IOS || MACCATALYST return FileSystem.Current.AppDataDirectory; #else return Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); #endif } public IEnumerable GetDirectoryContents(string path) { if (!Directory.Exists(path)) return Enumerable.Empty(); var items = new List(); // Добавляем ".." если не корень var parent = Directory.GetParent(path); if (parent != null) { items.Add(new FileSystemItem { Name = "..", FullName = parent.FullName, IsDirectory = true }); } var dirs = Directory.GetDirectories(path) .Select(d => new FileSystemItem { Name = Path.GetFileName(d), FullName = d, IsDirectory = true }); var files = Directory.GetFiles(path) .Select(f => new FileSystemItem { Name = Path.GetFileName(f), FullName = f, IsDirectory = false }); items.AddRange(dirs.OrderBy(d => d.Name)); items.AddRange(files.OrderBy(f => f.Name)); return items; } } }