April 2018
Intermediate to advanced
280 pages
8h 37m
English
We will extend our console application to list all the S3 buckets. We will add another function named listS3Buckets to the program and invoke that function after the createS3Bucket() function.
Add the following function to your application:
static void listS3Buckets() { try { IAmazonS3 s3Client = new AmazonS3Client(); ListBucketsResponse list_bucket_response = s3Client.ListBuckets(); foreach (S3Bucket bucket_object in list_bucket_response.Buckets) { Console.WriteLine("Bucket Name: {0}", bucket_object.BucketName); } } catch (AmazonS3Exception s3Exception) { Console.WriteLine("Error!!"); Console.WriteLine(s3Exception.ErrorCode); }}
Invoke this function by calling it from the main() function:
public static void Main(string[] ...