public OperationResponse CopyFolder(string sourceBucket, string sourceKey, string destinationBucket, string destinationKey, bool overwriteDestinationFolder, RegionEndpoint region) { var operationResponse = new OperationResponse(); try { if (overwriteDestinationFolder) { operationResponse = this.DeleteFolder(destinationBucket, destinationKey, region); } this.IsValid(_awsAccessKey, _awsSecretAccessKey, sourceBucket, sourceKey, destinationBucket, destinationKey, region); using (var client = new AmazonS3Client(_awsAccessKey, _awsSecretAccessKey, region)) { S3DirectoryInfo origin = new S3DirectoryInfo(client, sourceBucket, sourceKey.ToSlashesFileSystem()); S3DirectoryInfo target = new S3DirectoryInfo(client, destinationBucket, destinationKey.ToSlashesFileSystem()); target.Create(); operationResponse.S3DirectoryInfo = origin.CopyTo(target); } operationResponse.StatusCode = System.Net.HttpStatusCode.OK; } catch (AmazonS3Exception amazonS3Exception) { if (amazonS3Exception.ErrorCode != null && (amazonS3Exception.ErrorCode.Equals("InvalidAccessKeyId") || amazonS3Exception.ErrorCode.Equals("InvalidSecurity"))) { operationResponse.Message = "Please check the provided AWS Credentials. If you haven't signed up for Amazon S3, please visit http://aws.amazon.com/s3"; operationResponse.StatusCode = System.Net.HttpStatusCode.InternalServerError; } else { operationResponse.Message = amazonS3Exception.Message; operationResponse.StatusCode = System.Net.HttpStatusCode.InternalServerError; } } catch (Exception oException) { operationResponse.Message = oException.Message; operationResponse.StatusCode = System.Net.HttpStatusCode.InternalServerError; } return(operationResponse); }