This repository was archived by the owner on Jan 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathAppSettingInfo.cs
53 lines (47 loc) · 1.95 KB
/
AppSettingInfo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Chromely.Core.Logging;
using System;
using System.IO;
namespace Chromely.Core.Infrastructure
{
public static class AppSettingInfo
{
public static string GetSettingsFilePath(ChromelyPlatform platform, string appName = "chromely", bool onSave = false)
{
try
{
var appSettingsDir = string.Empty;
var fileName = $"{appName}_appsettings.config";
switch (platform)
{
case ChromelyPlatform.Windows:
appSettingsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "chromely");
break;
case ChromelyPlatform.Linux:
appSettingsDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData, Environment.SpecialFolderOption.DoNotVerify), "chromely");
break;
case ChromelyPlatform.MacOSX:
appSettingsDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal, Environment.SpecialFolderOption.DoNotVerify);
appSettingsDir = appSettingsDir.Replace("/Documents", "/Library/Application Support/chromely/");
break;
}
if (onSave)
{
Directory.CreateDirectory(appSettingsDir);
if (Directory.Exists(appSettingsDir))
{
return Path.Combine(appSettingsDir, fileName);
}
}
else
{
return Path.Combine(appSettingsDir, fileName);
}
}
catch (Exception exception)
{
Logger.Instance.Log.Error(exception);
}
return null;
}
}
}