If you would like to list all "subdirectories" in "Common\Service1" directory you can use something like this:
var directory = blobContainer.GetDirectoryReference(@"Common/Service1");
var folders = directory.ListBlobs().Where(b => b as CloudBlobDirectory != null).ToList();
foreach (var folder in folders)
{
Console.WriteLine(folder.Uri);
}
Full code sample:
var random = new Random();
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var cloudBlobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = cloudBlobClient.GetContainerReference("test-container");
blobContainer.CreateIfNotExists();
string[] objects = new[]
{
@"Common\Service1\Type1\Object1", @"Common\Service1\Type1\Object2", @"Common\Service1\Type2\Object1",
@"Common\Service1\Type2\Object2", @"Common\Service1\Type3\Object1", @"Common\Service1\Type3\Object2",
@"Common\Service1\Type3\Object3"
};
foreach (var newObject in objects)
{
var newBlob = blobContainer.GetBlockBlobReference(newObject);
var buffer = new byte[1024];
random.NextBytes(buffer);
newBlob.UploadFromByteArray(buffer,0,buffer.Length);
}
var directory = blobContainer.GetDirectoryReference(@"Common/Service1");
var folders = directory.ListBlobs().Where(b => b as CloudBlobDirectory != null).ToList();
foreach (var folder in folders)
{
Console.WriteLine(folder.Uri);
}
This will output Uri for Type1,Type2 and Type3 directory.