As the title mentions, I am trying to loop through blobs within a container. Right now I have a storage account with a blob container containing .txt files. But I also have a couple of blob directories (e.g. containerName/anotherFolder/more.txt)
Currently my code looks like this.
container = blobClient.GetContainerReference("myContainer");
BlobResultSegment allBlobs = await container.ListBlobsSegmentedAsync(null);
foreach (IListBlobItem blob in allBlobs.Results)
{
try
{
CloudBlockBlob blockblob = (CloudBlockBlob)blob;
...
...
...
}
catch(Exception e)
{
continue;
}
}
I am wondering if there is a better way than using a try/catch statement. Currently I have it because folders cannot be cast to cloudBlockBlobs.
*Note, I do not need the files within the folder, only the blobs within the first container.