A bucket is a container for objects stored in OSS. Every object is contained in a bucket. This topic describes how to delete a bucket.

For the complete code used to create a bucket, visit GitHub.

  • Before you delete a bucket, you must delete all objects in the bucket, LiveChannel objects, and fragments generated by multipart uploads. For more information about deleting a LiveChannel object, see LiveChannel.
  • To delete the parts generated by multipart upload, call ListMultipartUploads to list all the parts, and then call AbortMultipartUpload to delete these parts.

The following code provides an example on how to delete a bucket:

using Aliyun.OSS;

// Initialize an OSSClient instance.
var client = new OssClient(endpoint, accessKeyId, accessKeySecret);

// Delete the bucket.
public void DeleteBucket(string bucketName)

        Console.WriteLine("Delete bucket succeeded");
    catch (Exception ex)
        Console.WriteLine("Delete bucket failed. {0}", ex.Message);

For more information about how to delete a bucket, see DeleteBucket.