-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
47 lines (41 loc) · 1.36 KB
/
App.xaml.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
using Newtonsoft.Json.Linq;
using System.IO;
using System.Windows;
namespace RFCL;
public partial class App : Application
{
private JObject jsonObject = JObject.Parse(File.ReadAllText("RFCL.json"));
private App()
{
if (!File.Exists("RFCL.json")) File.WriteAllText("RFCL.json", "{}");
Version();
}
private void Version()
{
if (jsonObject["Version"] == null)
{
jsonObject["Version"] = new JObject();
jsonObject["Version"]["Select"] = 1;
jsonObject["Version"]["Path"] = new JArray();
JArray versionArray = (JArray)jsonObject["Version"]["Path"];
if (versionArray.Count == 0)
{
var official = new JObject
{
{ "Id", 0 },
{ "Name", "官方启动器目录" },
{ "Path", $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\.minecraft" }
};
var local = new JObject
{
{ "Id", 1 },
{ "Name", "当前启动器目录" },
{ "Path", $"{Directory.GetCurrentDirectory()}\\.minecraft" }
};
versionArray.Add(official);
versionArray.Add(local);
}
File.WriteAllText("RFCL.json", jsonObject.ToString());
}
}
}