1
0
mirror of synced 2024-11-15 01:33:51 +00:00
PettingZoo/PettingZoo.Core/Settings/PettingZooPaths.cs

27 lines
887 B
C#
Raw Normal View History

using System;
using System.IO;
using System.Reflection;
namespace PettingZoo.Core.Settings
{
public static class PettingZooPaths
{
public static string AppDataRoot { get; }
public static string InstallationRoot { get; }
static PettingZooPaths()
{
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (appDataPath == null)
throw new IOException("Could not resolve application data path");
AppDataRoot = Path.Combine(appDataPath, @"PettingZoo");
if (!Directory.CreateDirectory(AppDataRoot).Exists)
throw new IOException($"Failed to create directory: {AppDataRoot}");
InstallationRoot = Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location ?? Assembly.GetExecutingAssembly().Location)!;
}
}
}