private static void DownloadFiles(IScreenshotService proxy) { var localFileName = ""; var validPath = false; while (!validPath) { Console.WriteLine("Enter your desired path to save the screenshots: "); localFileName = Console.ReadLine(); try { Directory.CreateDirectory(localFileName); validPath = true; } catch (DirectoryNotFoundException e) { Console.WriteLine("The path you entered is not valid"); validPath = false; } } var request = new FileDownloadMessage(); request.FileMetaData = new FileMetaData(localFileName, "", ""); Console.WriteLine("Do you want to download all screenshots? Y/N"); var input = Console.ReadLine(); var downloadAll = input.ToUpper() == "Y"; var url = ""; if (!downloadAll) { Console.WriteLine("Write the URL of which you want to download: "); url = Console.ReadLine(); request.FileMetaData.Url = url; } try { using (FileDownloadReturnMessage response = downloadAll ? proxy.DownloadAllFiles(request) : proxy.DownloadFile(request)) { if (response != null && response.FileByteStream != null && !String.IsNullOrWhiteSpace(response.DownloadedFileMetadata.LocalFileName)) { SaveFile(response.FileByteStream, response.DownloadedFileMetadata.LocalFileName); Console.WriteLine("The download was successful."); } else { Console.WriteLine("Couldn't find the specified url"); } } } catch (Exception e) { Console.WriteLine("An error occured with the download."); } }