I have a question about my project... I need to know how to list all folders (in a string list or something) from a Windows Azure blob storage... I allready have my BlobClient a
Try this code. It makes use of Storage Client library 2.0.3:
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudBlobContainer blobContainer = storageAccount.CreateCloudBlobClient().GetContainerReference("wad-control-container");
string blobPrefix = null;
bool useFlatBlobListing = false;
var blobs = blobContainer.ListBlobs(blobPrefix, useFlatBlobListing, BlobListingDetails.None);
var folders = blobs.Where(b => b as CloudBlobDirectory != null).ToList();
foreach (var folder in folders)
{
Console.WriteLine(folder.Uri);
}
If you're using Storage Client Library 1.8 (i.e. previous to version 2.0), try this code:
var storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = cloudBlobClient.GetContainerReference("wad-control-container");
IEnumerable blobs = container.ListBlobs(new BlobRequestOptions()
{
UseFlatBlobListing = false,
});
var folders = blobs.Where(b => b as CloudBlobDirectory != null);
foreach (var folder in folders)
{
Console.WriteLine(folder.Uri);
}