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

Unable to Read Blob Storage account Directories and sub Directories

我正在尝试读取存储帐户的目录和子目录,但无法读取,下面是示例代码和附加的 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);
            }

文件夹结构:

容器和文件夹:

根据你的捕获,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);
    }

我这边的测试结果: