c# - List all containers and blobs -
i working on azure local development storage containers , blobs. want able display containers , blobs in listbox treeview of local development storage. code:
public list<string> listcontainer() { list<string> blobs = new list<string>(); // retrieve storage account connection string. cloudstorageaccount storageaccount = cloudstorageaccount.parse( cloudconfigurationmanager.getsetting("azurestorageconnectionstring")); // create blob client. cloudblobclient blobclient = storageaccount.createcloudblobclient(); //get list of blob above container ienumerable<cloudblobcontainer> containers = blobclient.listcontainers(); foreach (cloudblobcontainer item in containers) { blobs.add(string.format("{0}", item.uri.segments[2])); } return blobs; }
here displaying containers. need display blobs each container has, subfolders.
you iterating containers, not blobs in containers. on each container need call listblobs.
your code like:
foreach (cloudblobcontainer item in containers) { foreach (ilistblobitem blob in item.listblobs()){ blobs.add(string.format("{0}", blob.uri.segments[2])); } }
Comments
Post a Comment