From 5f7fefdc32b90b420fa2aa8ed070ae4b6200b2f6 Mon Sep 17 00:00:00 2001 From: STAM Date: Sat, 7 Mar 2020 00:48:16 +0300 Subject: [PATCH] fixed EpicMorg/UniversalValveToolbox#3 picMorg/UniversalValveToolbox#7 fixed https://github.com/EpicMorg/UniversalValveToolbox/issues/3 fixed https://github.com/EpicMorg/UniversalValveToolbox/issues/7 --- src/UniversalValveToolbox/Utils/JsonFileUtil.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/UniversalValveToolbox/Utils/JsonFileUtil.cs b/src/UniversalValveToolbox/Utils/JsonFileUtil.cs index 46837ee..8946311 100644 --- a/src/UniversalValveToolbox/Utils/JsonFileUtil.cs +++ b/src/UniversalValveToolbox/Utils/JsonFileUtil.cs @@ -10,7 +10,13 @@ namespace UniversalValveToolbox.Utils { static class JsonFileUtil { public static T ReadValue(string path) => JsonConvert.DeserializeObject(File.ReadAllText(path)); - public static T[] ReadValues(string directoryPath) => Directory.GetFiles(directoryPath, "*").Select(path => ReadValue(path)).ToArray(); + public static T[] ReadValues(string directoryPath) { + if (!Directory.Exists(directoryPath)) { + Directory.CreateDirectory(directoryPath); + } + + return Directory.GetFiles(directoryPath, "*").Select(path => ReadValue(path)).ToArray(); + } public static List ReadListValues(string directoryPath) => new List(ReadValues(directoryPath));