如何列出目录 Azure 中包含的 blob

How do I list blobs contained in a directory Azure

所以我试图列出虚拟文件夹中包含的 blob,我们称它为 "VF"

我试过很多方法例如:

var storageAccount = CloudStorageAccount.Parse("...");

var blobClient = storageAccount.CreateCloudBlobClient();

var container = blobClient.GetContainerReference("Container_Name");

List<IListBlobItem> blobslist = container.ListBlobsSegmentedAsync("VF", true).ToList();

但我收到如下错误:

Error: Argument 2: cannot convert from 'bool' to 'Microsoft.WindowsAzure.Storage.Blobl.BlobContinuationToken"}

我正在尝试使用 API 来 return 文件内容,这就是我遇到麻烦和使用不正确方法的原因吗?

非常感谢任何帮助

您需要正确实现BlobContinuationToken的用法。

像这样尝试

if (CloudStorageAccount.TryParse(connectionString, out CloudStorageAccount storageAccount))
{
    var context = new OperationContext();
    var options = new BlobRequestOptions();
    var cloudBlobClient = storageAccount.CreateCloudBlobClient();
    var cloudBlobContainer = cloudBlobClient.GetContainerReference(blobContainerName);
    BlobContinuationToken blobContinuationToken = null;
    do
    {
        var results = await cloudBlobContainer.ListBlobsSegmentedAsync(null, true, BlobListingDetails.All,
            null, blobContinuationToken, options, context);
        blobContinuationToken = results.ContinuationToken;
        foreach (var item in results.Results)
        {
            //do what you want with each blob
        }
    } while (blobContinuationToken != null);
}