-
Notifications
You must be signed in to change notification settings - Fork 0
/
DirStruct.cs
38 lines (32 loc) · 1.13 KB
/
DirStruct.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
using System;
using System.IO;
using Newtonsoft.Json;
namespace Unpde {
/// <summary>
/// 读取附加的目录结构文件
/// </summary>
public static class DirStruct {
/// <summary>
/// 读取
/// </summary>
/// <param name="Version"></param>
public static uint[] Read(String Version) {
Console.WriteLine(Version);
// 声明数组变量
uint[] DirStructList = [];
string JsonPath = Path.Combine(Directory.GetCurrentDirectory(), "DirStruct", $"offset_{Version}.json");
Console.WriteLine(JsonPath);
if (File.Exists(JsonPath)) {
try {
string Json = File.ReadAllText(JsonPath);
DirStructList = JsonConvert.DeserializeObject<uint[]>(Json) ?? []; // 正确初始化空数组
} catch (Exception ex) {
Console.WriteLine("解析JSON文件时出错: " + ex.Message);
}
} else {
Console.WriteLine("未找到目录结构文件");
}
return DirStructList;
}
}
}