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