From 10153a9bd2732fdcb4b86ce7ace3499c1c01e36e Mon Sep 17 00:00:00 2001 From: adroslice Date: Sun, 1 Dec 2019 17:05:00 +0100 Subject: [PATCH] Attempt to fix File Path handling - Now uses unix standard frontslashes for directories internally - Converts the backslashes windows returns to frontslashes - Changed default paths --- BFR/MainWindow.xaml.cs | 11 +++++------ BFR/Models/FileModel.cs | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/BFR/MainWindow.xaml.cs b/BFR/MainWindow.xaml.cs index 94a03c9..da35540 100644 --- a/BFR/MainWindow.xaml.cs +++ b/BFR/MainWindow.xaml.cs @@ -7,14 +7,13 @@ using System.Text.RegularExpressions; using Avalonia; using Avalonia.Controls; +using Avalonia.VisualTree; using Avalonia.Markup.Xaml; +using Avalonia.LogicalTree; using BFR.Helpers; using BFR.DataModels; -using Avalonia.Interactivity; using Avalonia.Input; -using Avalonia.LogicalTree; -using Avalonia.VisualTree; namespace BFR { @@ -26,8 +25,8 @@ namespace BFR public async Task OpenDirectoryButtonClick() => OpenDirectory(await new OpenFolderDialog() { Directory = WorkingDirectory }.ShowAsync(this)); public void OpenDirectory(string directory) { - WorkingDirectory = directory; - AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x))); + WorkingDirectory = directory.Replace('\\', '/'); + AllFiles.ReplaceAll(Directory.GetFiles(WorkingDirectory).Select(x => new FileModel(x.Replace('\\', '/')))); Filter(); } @@ -137,7 +136,7 @@ namespace BFR { AvaloniaXamlLoader.Load(this); DataContext = this; - OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home"); + OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:/Users/" : @"/home/"); HandleEvents = true; OperationsListBox = this.Find("OperationsListBox"); } diff --git a/BFR/Models/FileModel.cs b/BFR/Models/FileModel.cs index dc0e5b9..ddfcb5b 100644 --- a/BFR/Models/FileModel.cs +++ b/BFR/Models/FileModel.cs @@ -27,8 +27,8 @@ get => $"{Directory}{FullName}"; set { - FullName = value.Substring(value.LastIndexOf('\\') + 1); - Directory = value.Substring(0, value.LastIndexOf('\\') + 1); + FullName = value.Substring(value.LastIndexOf('/') + 1); + Directory = value.Substring(0, value.LastIndexOf('/') + 1); } }