

 **此页面仅适用于使用文件库和 2012 年原始 REST API 的 Amazon Glacier 服务的现有客户。**

如果您正在寻找归档存储解决方案，建议使用 Amazon S3 中的 Amazon Glacier 存储类别 S3 Glacier Instant Retrieval、S3 Glacier Flexible Retrieval 和 S3 Glacier Deep Archive。要了解有关这些存储选项的更多信息，请参阅 [Amazon Glacier 存储类别](https://www.amazonaws.cn/s3/storage-classes/glacier/)。

Amazon Glacier（最初基于保管库的独立服务）不再接受新客户。Amazon Glacier 是一项独立的服务 APIs ，拥有自己的服务，可将数据存储在文件库中，不同于亚马逊 S3 和 Amazon S3 Glacier 存储类别。在 Amazon Glacier 中，您现有的数据将确保安全，并且可以无限期地访问。无需进行迁移。对于低成本、长期的存档存储， Amazon 建议[使用 Amazon S3 Glacier 存储类别，这些存储类别](https://www.amazonaws.cn/s3/storage-classes/glacier/)基于S3存储桶 APIs、完全 Amazon Web Services 区域 可用性、更低的成本和 Amazon 服务集成，可提供卓越的客户体验。如果您希望加强功能，可以考虑使用我们的 [Amazon 将数据从 Amazon Glacier 文件库传输到 Amazon S3 Glacier 存储类别的解决方案指南](https://www.amazonaws.cn/solutions/guidance/data-transfer-from-amazon-s3-glacier-vaults-to-amazon-s3/)，迁移到 Amazon S3 Glacier 存储类别。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Amazon Glacier 删除档案 适用于 .NET 的 Amazon SDK
<a name="deleting-an-archive-using-dot-net"></a>

适用于.NET 的 Amazon SDK APIs 提供的[高级版本和低级](using-aws-sdk.md)版本都提供了一种删除档案的方法。

**Topics**
+ [使用的高级别 API 删除档案 适用于 .NET 的 Amazon SDK](#delete-archive-using-dot-net-high-level)
+ [使用低级 API 删除档案 适用于 .NET 的 Amazon SDK](#delete-archive-using-dot-net-low-level)

## 使用的高级别 API 删除档案 适用于 .NET 的 Amazon SDK
<a name="delete-archive-using-dot-net-high-level"></a>

该高级 API 的 `ArchiveTransferManager` 类提供了您可以用来删除档案的 `DeleteArchive` 方法。

### 示例：使用的高级别 API 删除档案 适用于 .NET 的 Amazon SDK
<a name="delete-archive-dot-net-high-level-example"></a>

以下 C\$1 代码示例使用的高级别 API 适用于 .NET 的 Amazon SDK 来删除档案。有关如何运行此示例的 step-by-step说明，请参阅[运行代码示例](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet)。您需要更新待删除档案 ID 旁显示的代码。

**Example**  

```
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();
    }
  }
}
```

## 使用低级 API 删除档案 适用于 .NET 的 Amazon SDK
<a name="delete-archive-using-dot-net-low-level"></a>

以下是使用 适用于 .NET 的 Amazon SDK删除档案的步骤。

 

1. 创建 `AmazonGlacierClient` 类（客户端）的实例。

   您需要指定存储要删除的档案的 Amazon 区域。您使用此客户端执行的所有操作都适用于该 Amazon 区域。

1. 通过创建一个 `DeleteArchiveRequest` 类的实例提供请求信息。

   您需要提供档案 ID、文件库名称和您的账户 ID。如果您不提供账户 ID，则系统会使用与您提供来对请求签名的证书相关联的账户 ID。有关更多信息，请参阅[Amazon SDKs 与 Amazon Glacier 搭配使用](using-aws-sdk.md)。

1. 以参数形式提供请求对象，运行 `DeleteArchive` 方法。

### 示例：使用的低级 API 删除档案 适用于 .NET 的 Amazon SDK
<a name="delete-archive-dot-net-low-level-example"></a>

以下 C\$1 示例说明了前面的步骤。该示例使用的低级 API 适用于 .NET 的 Amazon SDK 来删除档案。

**注意**  
有关底层 REST API 的信息，请参阅[删除档案（DELETE archive）](api-archive-delete.md)。

 有关如何运行此示例的 step-by-step说明，请参阅[运行代码示例](using-aws-sdk-for-dot-net.md#setting-up-and-testing-sdk-dotnet)。您需要更新待删除档案 ID 旁显示的代码。

**Example**  

```
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);
    }
  }
}
```