我如何成为从我的Azure存储容器中的所有斑点,而不是只有斑点的根源在哪里?
private CloudBlobContainer GetCloudBlobContainer()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=*;AccountKey=*;EndpointSuffix=core.windows.net");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("test123");
return container;
}
public ActionResult ListBlobs()
{
CloudBlobContainer container = GetCloudBlobContainer();
List<string> blobs = new List<string>();
BlobResultSegment resultSegment = container.ListBlobsSegmentedAsync(null).Result;
foreach (IListBlobItem item in resultSegment.Results)
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
blobs.Add(blob.Name);
}
else if (item.GetType() == typeof(CloudPageBlob))
{
CloudPageBlob blob = (CloudPageBlob)item;
blobs.Add(blob.Name);
}
//Directory
else if (item.GetType() == typeof(CloudBlobDirectory))
{
CloudBlobDirectory dir = (CloudBlobDirectory)item;
blobs.Add(dir.Uri.ToString());
}
}
return View(blobs);
}
该代码只返回根目录的斑点。但我想也得到一个目录内的斑点。
谢谢
调用useFlatBlobListing
方法时请注明ListBlobsSegmentedAsync
为true。