试试看看这个代码。代码假定您的blob容器中的所有Blob都是类型块blob。
存储客户端库2.0:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudBlobContainer blobContainer = storageAccount.CreateCloudBlobClient().GetContainerReference("images");
var blobs = blobContainer.ListBlobs(null, true, BlobListingDetails.All).Cast<CloudBlockBlob>();
foreach (var blockBlob in blobs)
{
Console.WriteLine("Name: " + blockBlob.Name);
Console.WriteLine("Size: " + blockBlob.Properties.Length);
Console.WriteLine("Content type: " + blockBlob.Properties.ContentType);
Console.WriteLine("Download location: " + blockBlob.Uri);
Console.WriteLine("=======================================");
}
存储客户端库1.7:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudBlobContainer blobContainer = storageAccount.CreateCloudBlobClient().GetContainerReference("images");
var blobs = blobContainer.ListBlobs(new BlobRequestOptions()
{
BlobListingDetails = BlobListingDetails.All,
UseFlatBlobListing = true,
}).Cast<CloudBlockBlob>();
foreach (var blockBlob in blobs)
{
Console.WriteLine("Name: " + blockBlob.Name);
Console.WriteLine("Size: " + blockBlob.Properties.Length);
Console.WriteLine("Content type: " + blockBlob.Properties.ContentType);
Console.WriteLine("Download location: " + blockBlob.Uri);
Console.WriteLine("=======================================");
}
的document.Uri应包含文件名。你需要将其去掉。 – tomasmcguinness 2013-02-15 13:14:41
你到底需要检索什么? – 2013-02-15 13:15:35
我猜我可以从uri中提取文件名。如果可能的话,我也喜欢文件大小。 – 2013-02-15 13:22:48