Tried using the ListBlobsSegmentedAsync method ,
but this returns only the blobs from the main parent directory level ..
But I need the entire list of blobs at one go from all the n levels of subdirectories.
BlobContinuationToken continuationToken = null;
bool useFlatBlobListing = true;
BlobListingDetails blobListingDetails = BlobListingDetails.None;
int maxBlobsPerRequest = 500;
var blobOptions = new BlobRequestOptions (true );
do
{
var listingResult = await cbDir.ListBlobsSegmentedAsync(useFlatBlobListing, blobListingDetails, maxBlobsPerRequest, continuationToken, null, null);
continuationToken = listingResult.ContinuationToken;
srcBlobList.AddRange(listingResult.Results);
} while (continuationToken != null);
Use this override of ListBlobsSegmentedAsync
method: https://msdn.microsoft.com/en-us/library/dn434672.aspx and make sure that you pass true
for useFlatBlobListing
parameter. This will list all blobs from all subdirectories.
UPDATE
This is the code I have used and it returns me the blobs in that subfolder and all subfolders inside that subfolder.
/// <summary>
/// Code to fetch blobs from "temp" folder inside "blah" blob container.
/// </summary>
private static void GetFilesInSubfolder()
{
var account = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
var blobClient = account.CreateCloudBlobClient();
var container = blobClient.GetContainerReference("blah");
var directory = container.GetDirectoryReference("temp");
var result = directory.ListBlobsSegmented(true, BlobListingDetails.None, 500, null, null, null);
var blobs = result.Results;
}