无法读取Blob存储帐户目录和子目录

时间:2019-12-17 21:26:47

标签: blob azure-storage-blobs blobstore azure-blob-storage blobstorage

我正在尝试读取存储帐户的目录和子目录,但无法读取,下面是示例代码和附加的Blob容器结构快照

示例代码:

  CloudBlobContainer container = Retrier<CloudBlobContainer>.TryWithDelayIncremental(() => blobclient.GetContainerReference(ContainerName), NoOfRetries, DelayInMilliSecs);

var directory = container.GetDirectoryReference(@"policies /Initiatives");
            var folders = directory.ListBlobs().Where(b => b as CloudBlobDirectory != null).ToList();
            foreach (var folder in folders)
            {
                Console.WriteLine(folder.Uri);
            }

文件夹结构:

folder structure

容器和文件夹:

container and folder

1 个答案:

答案 0 :(得分:0)

根据您的捕获,policies是容器的名称,如果要获取容器policies中/ Initiatives下的文件夹的所有URI,则目录引用名称中不应包含容器名称,请尝试以下代码:

    CloudBlobContainer container = blobClient.GetContainerReference("policies");

    var directory = container.GetDirectoryReference(@"Initiatives");
    var folders = directory.ListBlobs().Where(b => b as CloudBlobDirectory != null).ToList();
    foreach (var folder in folders)
    {
        Console.WriteLine(folder.Uri);
    }

测试结果在我这一边: enter image description here enter image description here