列出Azure Blob存储中的文件 [英] List Files in Azure Blob Storage
本文介绍了列出Azure Blob存储中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试列出我的Blob中的所有jpg文件.当我使用此代码
I am trying to list all the jpg files in my blob. When I use this code
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs();
列出了该特定Blob中的所有文件
All the files in that particular blob are listed
我试图修改以上代码,但修改后的代码未列出任何内容.
I have tried to modify the above code but the modified code does not list anything.
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs().OfType<CloudBlobContainer>().OrderByDescending(b => b.Name).Where(b => b.Name.EndsWith(".jpg"));
推荐答案
只是正确地解决了这个问题:问题是查询代码无意中检查了容器中的容器,而不是<容器中的em>斑点:
Just to close out this question properly: The issue is that the query code is inadvertently checking for containers within the container, not blobs within the container:
CloudStorageAccount storageAccount1 = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("ConnString"));
CloudBlobContainer container1 = blobClient.GetContainerReference(imageFolder);
var blobs = container1.ListBlobs().OfType<CloudBlobContainer>().OrderByDescending(b => b.Name).Where(b => b.Name.EndsWith(".jpg"));
最后一行应更改为:
var blobs = container1.ListBlobs().OfType<CloudBlockBlob>()...
这篇关于列出Azure Blob存储中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文