diff --git a/Wobble/Logging/Logger.cs b/Wobble/Logging/Logger.cs index 8234500..4a4b1d0 100644 --- a/Wobble/Logging/Logger.cs +++ b/Wobble/Logging/Logger.cs @@ -23,7 +23,7 @@ static Logger() => /// /// The folder which contains all the logs. /// - public static string LogsFolder => Path.Join(AppDomain.CurrentDomain.BaseDirectory, "Logs"); + public static string LogsFolder => Path.Join(WobbleGame.WorkingDirectory, "Logs"); /// /// The minimum log level required to log messages. diff --git a/Wobble/WobbleGame.cs b/Wobble/WobbleGame.cs index 8b2ab2c..d7c8977 100644 --- a/Wobble/WobbleGame.cs +++ b/Wobble/WobbleGame.cs @@ -34,10 +34,34 @@ public abstract class WobbleGame : Game { static readonly Predicate _beginCalled; + private static string _workingDirectory; + /// /// The current working directory of the executable. /// - public static string WorkingDirectory => AppDomain.CurrentDomain.BaseDirectory; + public static string WorkingDirectory + { + get + { + if (!string.IsNullOrEmpty(_workingDirectory)) + { + return _workingDirectory; + } + _workingDirectory = AppDomain.CurrentDomain.BaseDirectory; + try + { + File.WriteAllText(Path.Join(_workingDirectory, ".WritableTest"), "test"); + File.Delete(Path.Join(_workingDirectory, ".WritableTest")); + } + catch (Exception e) + when (e is UnauthorizedAccessException || e is IOException) + { + _workingDirectory = Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Quaver"); + Directory.CreateDirectory(_workingDirectory); + } + return _workingDirectory; + } + } /// /// Device period to pass to AudioManager.Initialize().