From 2f669cc08bf3343f18b6c2341b7c9733bb9f619f Mon Sep 17 00:00:00 2001 From: Josh Creek <8179928+jcreek@users.noreply.github.com> Date: Thu, 30 Nov 2023 13:09:53 +0000 Subject: [PATCH] feat(*): Enable adding missing directories for day creator --- AdventOfCode/DayCreator/Program.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/AdventOfCode/DayCreator/Program.cs b/AdventOfCode/DayCreator/Program.cs index 307eb58..f47ee64 100644 --- a/AdventOfCode/DayCreator/Program.cs +++ b/AdventOfCode/DayCreator/Program.cs @@ -18,6 +18,22 @@ string yearPath = Path.GetFullPath(Path.Combine(newPathBase, "AOC.Tests", $"Y{ye string dataPath = Path.GetFullPath(Path.Combine(yearPath, "Data", $"Day{day}.dat")); string tasksPath = Path.GetFullPath(Path.Combine(yearPath, "Tasks", $"Day{day}.txt")); +// Check and create missing directories +if (!Directory.Exists(yearPath)) +{ + Directory.CreateDirectory(yearPath); +} + +if (!Directory.Exists(Path.Combine(yearPath, "Data"))) +{ + Directory.CreateDirectory(Path.Combine(yearPath, "Data")); +} + +if (!Directory.Exists(Path.Combine(yearPath, "Tasks"))) +{ + Directory.CreateDirectory(Path.Combine(yearPath, "Tasks")); +} + // Create data file using (FileStream fs = File.Create(dataPath));