Menu
Amazon Glacier
Developer Guide (API Version 2012-06-01)

Deleting an Archive in Amazon Glacier Using the AWS SDK for .NET

Both the high-level and low-level APIs provided by the AWS SDK for .NET provide a method to delete an archive.

Deleting an Archive Using the High-Level API of the AWS SDK for .NET

The ArchiveTransferManager class of the high-level API provides the DeleteArchive method you can use to delete an archive.

Example: Deleting an Archive Using the High-Level API of the AWS SDK for .NET

The following C# code example uses the high-level API of the AWS SDK for .NET to delete an archive. For step-by-step instructions on how to run this example, see Running Code Examples. You need to update the code as shown with the archive ID of the archive you want to delete.

Copy
using System; using Amazon.Glacier; using Amazon.Glacier.Transfer; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class ArchiveDeleteHighLevel { static string vaultName = "examplevault"; static string archiveId = "*** Provide archive ID ***"; public static void Main(string[] args) { try { var manager = new ArchiveTransferManager(Amazon.RegionEndpoint.USWest2); manager.DeleteArchive(vaultName, archiveId); Console.ReadKey(); } catch (AmazonGlacierException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("To continue, press Enter"); Console.ReadKey(); } } }

Deleting an Archive Using the Low-Level API AWS SDK for .NET

The following are the steps to delete an using the AWS SDK for .NET.

  1. Create an instance of the AmazonGlacierClient class (the client).

    You need to specify an AWS region where the archive you want to delete is stored. All operations you perform using this client apply to that region.

  2. Provide request information by creating an instance of the DeleteArchiveRequest class.

    You need to provide an archive ID, a vault name, and your account ID. If you don't provide an account ID, then account ID associated with the credentials you provide to sign the request is assumed. For more information, see Using the AWS SDKs with Amazon Glacier.

  3. Execute the DeleteArchive method by providing the request object as a parameter.

Example: Deleting an Archive Using the Low-Level API of the AWS SDK for .NET

The following C# example illustrates the preceding steps. The example uses the low-level API of the AWS SDK for .NET to delete an archive.

Note

For information about the underlying REST API, see Delete Archive (DELETE archive).

For step-by-step instructions on how to run this example, see Running Code Examples. You need to update the code as shown with the archive ID of the archive you want to delete.

Copy
using System; using Amazon.Glacier; using Amazon.Glacier.Model; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class ArchiveDeleteLowLevel { static string vaultName = "examplevault"; static string archiveId = "*** Provide archive ID ***"; public static void Main(string[] args) { AmazonGlacierClient client; try { using (client = new AmazonGlacierClient(Amazon.RegionEndpoint.USWest2)) { Console.WriteLine("Deleting the archive"); DeleteAnArchive(client); } Console.WriteLine("Operations successful. To continue, press Enter"); Console.ReadKey(); } catch (AmazonGlacierException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("To continue, press Enter"); Console.ReadKey(); } static void DeleteAnArchive(AmazonGlacierClient client) { DeleteArchiveRequest request = new DeleteArchiveRequest() { VaultName = vaultName, ArchiveId = archiveId }; DeleteArchiveResponse response = client.DeleteArchive(request); } } }