AWS S3DirectoryInfo Delete() not deleting

Viewed 22

I have a pretty straight forward call to delete a folder and all its contents from S3.

The Call

var response = gfAwsClient.S3DeleteEvent(Globals.globalEventPathAWS, "fgevents-lowres-dev", clouddir);

The method is:

public async Task<string> S3DeleteEvent(string basedirectory, string bucketName, string folderName)
            {
                if (folderName != null)
                {
                    var dirInfo = new S3DirectoryInfo(client, bucketName, basedirectory + folderName);
                    dirInfo.Delete(true); //set to true to delete everything inside too
                }            
                return null;
            }

The value of the concated basedirectory + folderName = "/Events/01/999/001/"

And the value of dirInfo = {fgevents-lowres-dev:\/Events/01/999/001/\}

It executes, but nothing seems to happen, I get no errors thrown, and I don't even see how to return a good or bad response back.

1 Answers

It does not want the leading "/" as the root.
So for the path I used:

Events/01/999/001

The full call is:

    string basedirectory = @"Events/01/";
    string folderName = @"999/001";
    string pathToDelete = Path.Combine(basedirectory, folderName);
                    var dirInfo = new S3DirectoryInfo(client, bucketName, pathToDelete);
                    dirInfo.Delete(true); //true deletes all files and current folder
Related