From 101bd09bf61a3163e98dd745511d700d2fb1ce0d Mon Sep 17 00:00:00 2001 From: Weston McNamara Date: Thu, 31 Dec 2020 10:49:14 -0500 Subject: [PATCH] Changed order outputs and downloads are done to prevent apod metadata from outputting after an error --- Program.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Program.cs b/Program.cs index 47b17b6..949506c 100644 --- a/Program.cs +++ b/Program.cs @@ -31,22 +31,23 @@ async static Task Main(string[] args) Console.WriteLine("Astronomy Picture Of The Day | Program Created by Weston McNamara\n"); - //Ouput the title, date, and an image explanation - Console.WriteLine(apod.title); - Console.WriteLine(apod.date + "\n\n"); - Console.WriteLine(apod.explanation + "\n\n"); - //After displaying that, download the background, and set the desktop background with the new image. using (var client = new WebClient()) { Console.WriteLine("Downloading Background..."); client.DownloadFile(apod.hdurl, "bg.jpg"); SetDesktopBackground(Path.GetFullPath("bg.jpg")); - Console.WriteLine("Background Updated!"); + Console.WriteLine("Background Updated!\n"); } + + //Ouput the title, date, and an image explanation + Console.WriteLine(apod.title); + Console.WriteLine(apod.date + "\n\n"); + Console.WriteLine(apod.explanation + "\n"); } catch (Exception e) { + //Console.WriteLine("\nException Caught!"); //Console.WriteLine("Message :{0} ", e.Message); Console.WriteLine("\nThe APOD today is not a format that can be set to a desktop background, such as a video. Please visit the official APOD website to view todays APOD. \n\nhttps://apod.nasa.gov/apod/astropix.html" );