From f4c694477459235350e4cd2fe0facdf255a31bd6 Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Thu, 14 Jan 2021 00:28:53 +0100 Subject: [PATCH] Fixed minor config flaw where empty lines were saved & loaded --- Code/IO/Config.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Code/IO/Config.cs b/Code/IO/Config.cs index 3c5fff6..47b6275 100644 --- a/Code/IO/Config.cs +++ b/Code/IO/Config.cs @@ -47,7 +47,13 @@ namespace Flowframes.IO List list = lines.ToList(); list.Add(key + "|" + value); list = list.OrderBy(p => p).ToList(); - File.WriteAllLines(configPath, list.ToArray()); + + string newFileContent = ""; + foreach(string line in list) + newFileContent += line + "\n"; + + File.WriteAllText(configPath, newFileContent.Trim()); + cachedLines = list.ToArray(); } @@ -155,7 +161,14 @@ namespace Flowframes.IO private static void Reload() { - cachedLines = File.ReadAllLines(configPath); + List validLines = new List(); + string[] lines = File.ReadAllLines(configPath); + foreach (string line in lines) + { + if(line != null && !string.IsNullOrWhiteSpace(line) && line.Length > 3) + validLines.Add(line); + } + cachedLines = validLines.ToArray(); } } }