Delete an Archive from a Vault in S3 Glacier by Using the Amazon SDK for .NET - Amazon S3 Glacier
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

This page is only for existing customers of the S3 Glacier service using Vaults and the original REST API from 2012.

If you're looking for archival storage solutions we suggest using the S3 Glacier storage classes in Amazon S3, S3 Glacier Instant Retrieval, S3 Glacier Flexible Retrieval, and S3 Glacier Deep Archive. To learn more about these storage options, see S3 Glacier storage classes and Long-term data storage using S3 Glacier storage classes in the Amazon S3 User Guide. These storage classes use the Amazon S3 API, are available in all regions, and can be managed within the Amazon S3 console. They offer features like Storage Cost Analysis, Storage Lens, advanced optional encryption features, and more.

Delete an Archive from a Vault in S3 Glacier by Using the Amazon SDK for .NET

The following C# code example uses the high-level API of the Amazon SDK for .NET to delete the archive that you uploaded in the previous step. In the code example, note the following:

  • The example creates an instance of the ArchiveTransferManager class for the specified Amazon S3 Glacier Region endpoint.

  • The code example uses the US West (Oregon) Region (us-west-2).

  • The example uses the Delete API operation of the ArchiveTransferManager class that's provided as part of the high-level API of the Amazon SDK for .NET.

For step-by-step instructions on how to run this example, see Running Code Examples. You must update the code as shown with the archive ID of the file that you uploaded in Step 3: Upload an Archive to a Vault in S3 Glacier.

Example — Deleting an Archive by Using the High-Level API of the Amazon SDK for .NET
using System; using Amazon.Glacier; using Amazon.Glacier.Transfer; using Amazon.Runtime; namespace glacier.amazon.com.docsamples { class ArchiveDeleteHighLevel_GettingStarted { 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); } 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(); } } }