示例#1
0
 private static void DownloadCard(PokemonCard card, string fileName)
 {
     using (var client = new ImageWebRequest())
     {
         try
         {
             client.DownloadFile(card.ImageUrlHiRes, fileName);
         }
         catch (WebException e)
         {
             if (e.Message.Contains("404"))
             {
                 try
                 {
                     client.DownloadFile(card.ImageUrl, fileName);
                 }
                 catch (Exception)
                 {
                     Console.Write("Failed to download image for: " + card.Name);
                 }
             }
             else
             {
                 Console.Write("Failed to download image for: " + card.Name);
             }
         }
     }
 }
示例#2
0
 private static void DownloadCard(string hiResUrl, string lowResUrl, string fileName)
 {
     using (var client = new ImageWebRequest())
     {
         try
         {
             client.DownloadFile(hiResUrl, fileName);
         }
         catch (WebException e)
         {
             if (e.Message.Contains("404"))
             {
                 client.DownloadFile(lowResUrl, fileName);
             }
         }
     }
 }