From fe43fe933d2489744e85d4e0052337fbe33adf01 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:21:36 +0200 Subject: [PATCH] Make paths cross-platform --- src/Markdowser/Utilities/Configuration.cs | 33 ++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/Markdowser/Utilities/Configuration.cs b/src/Markdowser/Utilities/Configuration.cs index f859e02..6975467 100644 --- a/src/Markdowser/Utilities/Configuration.cs +++ b/src/Markdowser/Utilities/Configuration.cs @@ -1,12 +1,39 @@ -using System; +using Syroot.Windows.IO; + +using System; using System.IO; +using System.Runtime.InteropServices; namespace Markdowser.Utilities; internal static class Configuration { - public static string DownloadPath => Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); - public static string ApplicationDataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(Markdowser)); + public static string DownloadPath + { + get + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return KnownFolders.Downloads.Path; + } + + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Downloads"); + } + } + + public static string ApplicationDataPath + { + get + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "StoneRed", nameof(Markdowser)); + } + + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StoneRed", nameof(Markdowser)); + } + } public static string SettingsFilePath => Path.Combine(ApplicationDataPath, "settings.json"); + public static string LogFilePath => Path.Combine(ApplicationDataPath, $"{nameof(Markdowser)}.log"); } \ No newline at end of file