Beispiel #1
0
 protected static void DownloadFile(IAsyncResult Result)
 {
     try {
         AmazonS3          s3  = Result.AsyncState as AmazonS3;
         GetObjectResponse r   = s3.EndGetObject(Result);
         string            dir = Path.GetDirectoryName(Settings.LocalDirectory + "/" + r.Key);
         if (!Directory.Exists(dir))
         {
             Directory.CreateDirectory(dir);
         }
         r.WriteResponseStreamToFile(Settings.LocalDirectory + "/" + r.Key);
     } catch (Exception ex) {
         ErrorCount++;
         Console.WriteLine(ex.Message);
     }
     DownloadCount--;
 }
Beispiel #2
0
        protected void DownloadFile(IAsyncResult Result)
        {
            string file = "unknown";

            try {
                AmazonS3          s3 = Result.AsyncState as AmazonS3;
                GetObjectResponse r  = s3.EndGetObject(Result);
                System.Console.WriteLine(r.Key);
                string dir = Path.GetDirectoryName(Settings.LocalDirectory + "/" + r.Key);
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                r.WriteResponseStreamToFile(Settings.LocalDirectory + "/" + r.Key);
            } catch (Exception ex) {
                ErrorCount++;
                System.Console.WriteLine(ex.Message);
                AddTextToConsole("ERROR:" + ex.Message + Environment.NewLine);
            }
            DownloadCount--;
        }