c# - Windows Universal App - Download all Blobs from Azure Container -
i have universal windows app.
i trying download blobs azure container when app starts. code:
public mainpage() { this.initializecomponent(); downloadblobs(); } public async void downloadblobs() { cloudstorageaccount storageaccount = new cloudstorageaccount(new storagecredentials("accountname", "accountkey"), true); cloudblobclient blobclient = storageaccount.createcloudblobclient(); cloudblobcontainer container = blobclient.getcontainerreference("containername"); //--------------------- int filename = 1; var client = storageaccount.createcloudblobclient(); blobcontinuationtoken continuationtoken = null; string prefix = null; bool useflatbloblisting = true; bloblistingdetails bloblistingdetails = bloblistingdetails.all; int maxblobsperrequest = 2500; list<ilistblobitem> blobs = new list<ilistblobitem>(); { var listingresult = await container.listblobssegmentedasync(prefix, useflatbloblisting, bloblistingdetails, maxblobsperrequest, continuationtoken, null, null); continuationtoken = listingresult.continuationtoken; blobs.addrange(listingresult.results); using (var filestream = system.io.file.openwrite(@"\newimages\" + filename + ".jpg")) { var blobreference = blobclient.getblobreferencefromserverasync(blobs.uri); file downloadedfile = new file(blobreference + ".jpg"); filename++; } } while (continuationtoken != null); } im getting errors on 2 lines:
var blobreference = blobclient.getblobreferencefromserverasync(blobs.uri); file downloadedfile = new file(blobreference + ".jpg"); my errors are:
listblobitem not contain definition of uri.
cannot declare variable of static type file.
and
cannot create instance of static class file.
you need enumerate blobs in container, container.listblobssegmentedasync(). container reference doesn't have list of blobs automatically downloaded it.
for reference, see here.
Comments
Post a Comment