【问题标题】:Deleting a folder from blob container从 blob 容器中删除文件夹
【发布时间】:2019-04-13 02:16:42
【问题描述】:

我需要从 Azure 存储帐户中的 blob 容器中删除一个文件夹。文件夹结构如下:

container -> failed -> profiles

我连接容器如下:

CloudBlobClient blobClient = StorageAccountManager.getStorageAccount(ConnectionString));
var container = blobClient.GetContainerReference(container_name);

我正在尝试如下引用特定文件夹:

var blob = container.GetBlockBlobReference(failed + "/" + directory);

我也尝试了以下方法:

((CloudBlob)blob).DeleteIfExists(); 
blob.DeleteIfExists();
blob.DeleteAsync();

但这些都没有删除我的 blob 存储中的文件夹。我错过了什么还是我做错了什么?

【问题讨论】:

  • 你需要使用 'GetDirectoryReference("your folder name")' 然后使用 deleteIfExists
  • 我应该将 GetDirectoryReference 分配给什么?
  • @Llazar 这个链接有效。是否可以解析所有文件夹以检查该文件夹存在于哪个文件夹中?
  • 以编程方式可以遍历文件夹文件,但您需要记住 Azure 存储没有文件夹的含义。

标签: c# asp.net .net azure-storage azure-blob-storage


【解决方案1】:

Azure 存储中的文件夹并没有真正创建或删除,只要其中存储有 blob,它们就存在。删除文件夹的方法是使用 ListBlobsSegmentedAsync 检索其中的所有 blob,并在每个 blob 上调用 DeleteIfExists()

【讨论】:

    猜你喜欢
    • 2020-01-02
    • 2016-04-16
    • 2016-07-29
    • 1970-01-01
    • 2020-01-01
    • 2018-04-13
    • 1970-01-01
    • 2021-10-09
    • 2020-05-10
    相关资源
    最近更新 更多