diff --git a/AdventOfCode/DayCreator/Program.cs b/AdventOfCode/DayCreator/Program.cs index 04790ec..307eb58 100644 --- a/AdventOfCode/DayCreator/Program.cs +++ b/AdventOfCode/DayCreator/Program.cs @@ -12,19 +12,22 @@ var day = Console.ReadLine().PadLeft(2, '0'); ; var currentLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; int ix = currentLocation.IndexOf("DayCreator"); var newPathBase = currentLocation.Substring(0, ix - 1); +var newDayCreatorBase = currentLocation.Substring(0, ix + "DayCreator".Length); -string yearPath = Path.GetFullPath(Path.Combine(newPathBase, $@"AOC.Tests\Y{year}\")); -string dataPath = Path.GetFullPath(Path.Combine(yearPath, $@"Data\")); -string tasksPath = Path.GetFullPath(Path.Combine(yearPath, $@"Tasks\")); +string yearPath = Path.GetFullPath(Path.Combine(newPathBase, "AOC.Tests", $"Y{year}")); +string dataPath = Path.GetFullPath(Path.Combine(yearPath, "Data", $"Day{day}.dat")); +string tasksPath = Path.GetFullPath(Path.Combine(yearPath, "Tasks", $"Day{day}.txt")); // Create data file -using (FileStream fs = File.Create($"{dataPath}Day{day}.dat")); +using (FileStream fs = File.Create(dataPath)); // Create task file -using (FileStream fs = File.Create($"{tasksPath}Day{day}.txt")); +using (FileStream fs = File.Create(tasksPath)); // Create code file -string text = File.ReadAllText("DayX.cs"); +var dayXPath = Path.GetFullPath(Path.Combine(newDayCreatorBase, "DayX.cs")); +string text = File.ReadAllText(dayXPath); text = text.Replace("YX", $"Y{year}"); text = text.Replace("DayX", $"Day{day}"); -File.WriteAllText($"{yearPath}Day{day}.cs", text); +var writePath = Path.GetFullPath(Path.Combine(yearPath, $"Day{day}.cs")); +File.WriteAllText(writePath, text);