From 9711275271b4d6d874ff6cfaae058326b64666c5 Mon Sep 17 00:00:00 2001 From: kianzzarrin Date: Fri, 16 Dec 2022 23:31:34 +0200 Subject: [PATCH] ensure directory --- LoadOrder/Shared/SharedUtil.cs | 4 +++- Version.props | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/LoadOrder/Shared/SharedUtil.cs b/LoadOrder/Shared/SharedUtil.cs index b6f80d5..514b3ce 100644 --- a/LoadOrder/Shared/SharedUtil.cs +++ b/LoadOrder/Shared/SharedUtil.cs @@ -22,6 +22,8 @@ internal class SharedUtil { internal static void Serialize(T obj, string filePath) { var serializer = new XmlSerializer(typeof(T)); using (StreamWriter writer = new StreamWriter(filePath)) { + var dirInfo = new FileInfo(filePath).Directory; + if (!dirInfo.Exists) dirInfo.Create(); using (var xmlWriter = new XmlTextWriter(writer)) { xmlWriter.Formatting = Formatting.Indented; serializer.Serialize(xmlWriter, obj, NoNamespaces); @@ -32,7 +34,7 @@ internal static void Serialize(T obj, string filePath) { public static T Deserialize(string filePath) where T : class { XmlSerializer ser = new XmlSerializer(typeof(T)); var dirInfo = new FileInfo(filePath).Directory; - if (dirInfo.Exists) dirInfo.Create(); + if (!dirInfo.Exists) dirInfo.Create(); using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { return ser.Deserialize(fs) as T; } diff --git a/Version.props b/Version.props index 357b1c5..a8429a2 100644 --- a/Version.props +++ b/Version.props @@ -1,5 +1,5 @@ - 1.15.6.* + 1.15.7.* \ No newline at end of file