【发布时间】:2021-12-21 01:28:02
【问题描述】:
我们有以下文件夹结构,我们在 Azure 数据湖中存储了数据。
我想列出 Data 目录中存在的所有 blob。 IE。 abc.txt,xyz.txt,lmn.txt,abc1.txt,xyz1.txt,lmn1.txt,abc2.txt,xyz2.txt,lmn2.txt,gh.txt,kim.txt,tae.txt,.. ..
我怎样才能获得仅在数据目录中的所有 blob?
我想从每年和每月的文件夹中获取所有用户的数据文件夹中存在的所有 blob。
代码:
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System;
using System.Collections.Generic;
namespace DataLake
{
class Program
{
static void Main(string[] args)
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("connection string");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("dev");
List<string> blobnames = new List<string>();
var allblobs = container.ListBlobs(useFlatBlobListing: true);
foreach (var b in allblobs)
{
//Console.WriteLine("\t" + b.Uri);
string name = ((CloudBlockBlob)b).Name;
// Console.WriteLine(name);
string[] names = name.Split('/');
blobnames.Add(names[names.Length - 1]);
}
foreach (var data in blobnames)
{
Console.WriteLine(data);
}
}
}
}
【问题讨论】:
-
您能指定您使用的编程语言吗?
-
我正在使用c#来实现这个
标签: azure blob azure-blob-storage azure-data-lake-gen2 blobstorage