简体   繁体   中英

How to get all/some files (CloudBlockBlob) from an Azure blob container?

I know I can get a specific file from an Azure blob container using its name, like this: CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob.txt");

Is there a way to get all the files in a List? I would like to do something like this, but unfortunately there is no such method: CloudBlockBlob blockBlobList = container. GetBlockBlobReferences (" . ");

If you're interested in getting a list of all blobs in a container, you can certainly do that.

var container = storageAccount.CreateCloudBlobClient().GetContainerReference("mycontainer");
var blobs = container.ListBlobs();

blobs variable will have a list of all blobs.

If it's CloudBlockBlobs that you want, casting could help.

var container = storageAccount.CreateCloudBlobClient().GetContainerReference("mycontainer");
var blobs = container.ListBlobs().Cast<CloudBlockBlob>();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM