-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfigInit.cs
More file actions
37 lines (31 loc) · 1.2 KB
/
ConfigInit.cs
File metadata and controls
37 lines (31 loc) · 1.2 KB
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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BackUpDesktop
{
internal class ConfigInit
{
public static string ConfigPath { get; set; } = "Config.json";
public static ConfigData Config { get; set; }
public async Task InitializeAsync()
{
var json = string.Empty;
if (!File.Exists(ConfigPath))
{
json = JsonConvert.SerializeObject(GenerateNewConfig(), Formatting.Indented);
File.WriteAllText("Config.json", json, new UTF8Encoding(false));
await Task.Delay(200);
}
json = File.ReadAllText(ConfigPath, new UTF8Encoding(false));
Config = JsonConvert.DeserializeObject<ConfigData>(json);
}
private static ConfigData GenerateNewConfig() => new ConfigData
{
Comment = "Please respect single / or \\, and delete example path, you can add all paths you want and more line too",
Path = new string[] { "C:\\Users\\%userprofile%\\exemple", "C:\\Windows\\exemple", "C:/Windows/SystemApps/exemple", "", "" },
};
}
}