From e6943924cc37ed91cba4fd2e2fcfa4ba0b945c86 Mon Sep 17 00:00:00 2001 From: Stone_Red <56473591+Stone-Red-Code@users.noreply.github.com> Date: Fri, 27 Jun 2025 13:01:16 +0200 Subject: [PATCH] Allow files paths without directory as output paths --- src/ARP-Scanner/Program.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/ARP-Scanner/Program.cs b/src/ARP-Scanner/Program.cs index 8f0fe1b..da716de 100644 --- a/src/ARP-Scanner/Program.cs +++ b/src/ARP-Scanner/Program.cs @@ -187,7 +187,10 @@ internal static class Program try { - _ = Directory.CreateDirectory(Path.GetDirectoryName(jsonPath) ?? string.Empty); + if (!string.IsNullOrWhiteSpace(Path.GetDirectoryName(jsonPath))) + { + _ = Directory.CreateDirectory(Path.GetDirectoryName(jsonPath)!); + } string json = JsonSerializer.Serialize(JsonResult.Parse([.. activeHosts], previouslyActiveHosts), jsonSerializerOptions); File.WriteAllText(jsonPath, json); @@ -216,7 +219,11 @@ internal static class Program try { - _ = Directory.CreateDirectory(Path.GetDirectoryName(csvPath) ?? string.Empty); + if (!string.IsNullOrWhiteSpace(Path.GetDirectoryName(csvPath))) + { + _ = Directory.CreateDirectory(Path.GetDirectoryName(csvPath)!); + } + File.WriteAllLines(csvPath, activeHostsTable.Select(row => string.Join(",", row))); if (!options.Silent)