在CloudBlobContainer中找不到Listblob() [英] Does not found Listblob() in CloudBlobContainer

查看:157
本文介绍了在CloudBlobContainer中找不到Listblob()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我需要容器的所有blob,但是在我的代码(如下所示)中,CloudBlobContainer变量容器中没有Listblob()方法.我想念什么吗?

In my app i want all the blob of my container but in my code (as below) there is not Listblob() method in CloudBlobContainer variable container. Am i missing something?

var credentials = new StorageCredentials("xxx", "a37bijfRGGdgaVU+ITEIi0Cp1VrbzMM7Bc9PbMOw2FPAz9twgR+lbTzqGhBfHeJe7UfEp4CXtLxqY5Ek0/5zdg==");
        var client = new CloudBlobClient(new Uri("https://xxx.blob.core.windows.net/"), credentials);
        var container = client.GetContainerReference("publicimage");

//this container variable has not ListBlobs() method
        foreach(IListBlobItem item in container.ListBlobsSegmentedAsync())
        {

        }

推荐答案

ListBlobs是一种同步方法,因此在不支持同步方法的平台(例如Windows Phone)上丢失.原因是在UI线程上调用同步方法会阻塞UI,并使应用程序无响应.

ListBlobs is a synchronous method and therefore is missing on platforms that do not support synchronous methods such as Windows Phone. The reason is that calling a synchronous method on a UI thread would block the UI and make the application unresponsive.

替代方法是使用* Async重载.但是,请注意,因为.NET中没有IEnumerable的异步对应项,所以没有ListBlobsAsync.因此,您应该调用 ListBlobsSegmentedAsync 并处理它返回的延续令牌.

The alternative is to use the *Async overloads. However, please note that there is no ListBlobsAsync, because there is no async counterpart of IEnumerable in .NET. So, you should call ListBlobsSegmentedAsync and handle the continuation token that it returns.

如果您想查看示例用法,我建议您查看Azure存储客户端库的单元测试(请参见

If you would like to see an example usage, I would recommend looking at Azure Storage Client Library's unit tests (see test CloudBlobContainerListBlobsSegmentedAsync in CloudBlobContainerTest.cs).

这篇关于在CloudBlobContainer中找不到Listblob()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆