private String DownloadWebPI()
 {
     String downloadLocation = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + Path.GetExtension(Resources.WebPIDownloadLoc));
     using(DownloadHelper downloadWebPI = new DownloadHelper())
     {
         downloadWebPI.Download(new Uri(Resources.WebPIDownloadLoc), downloadLocation);
     }
     return downloadLocation;
 }
Exemple #2
0
 private string Download()
 {
     if (RetryCount == 0)
     {
         RetryCount = 3; //Try 3 times before giving up if not specified.
     }
     String tempLocation = String.Empty;
     int tryCount = 0;
     while (tryCount < RetryCount)
     {
         try
         {
             tempLocation = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + Path.GetExtension(DownloadLoc.ToString()));
             using (DownloadHelper helper = new DownloadHelper())
             {
                 helper.Download(new Uri(DownloadLoc), tempLocation);
             }
             break;
         }
         catch (Exception ex)
         {
             tryCount++;
             if (tryCount < RetryCount == false)
             {
                 throw ex;
             }
             else
             {
                 String errorMessage = String.Format(CultureInfo.InvariantCulture, "Retry count - {0}. Error downloading the file - {1}", tryCount, ex.Message);
                 Console.WriteLine(errorMessage);
             }
         }
     }
     return tempLocation;
 }