fix json file not exists case

This commit is contained in:
2024-06-10 21:33:10 +02:00
parent ef808ac62b
commit ff4c352dee

View File

@@ -22,7 +22,7 @@ namespace OwnChar.Data.Providers.JsonFile
protected void LoadFile() protected void LoadFile()
{ {
if (JsonConvert.DeserializeObject<JsonFile>(File.ReadAllText(JsonFilePath), CreateJsonSerializerSettings()) is JsonFile jsonFile) if (File.Exists(JsonFilePath) && JsonConvert.DeserializeObject<JsonFile>(File.ReadAllText(JsonFilePath), CreateJsonSerializerSettings()) is JsonFile jsonFile)
JsonFile = jsonFile; JsonFile = jsonFile;
JsonFile ??= new(); JsonFile ??= new();
} }