I'm using azure blobstorage in c#, is there a way, a method to get the list of files from a given specific folder? like get all file names inside this url https://prueba.blob.core.windows.net/simem/UAL/Dato de archivo prueba No1/2022/1/16 i know that using container.GetBlobs() i would get all files but not from a specific folder
CodePudding user response:
Just use
var results = await container.ListBlobsSegmentedAsync(prefix, true, BlobListingDetails.None, null, null, null, null);
CodePudding user response:
You can get file names from a specific folder using BlobServiceClient
and GetBlobs
and by using below code in C# Console App and I followed Microsoft-Document and @Cindy Pau's answer:
using Azure.Storage.Blobs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
string cs= "Connection String of Storage Account";
string f = "test";
BlobServiceClient b = new BlobServiceClient(cs);
string c = "pool";
BlobContainerClient containerClient =b.GetBlobContainerClient(c);
var bs= containerClient.GetBlobs(prefix: f);
foreach (var x in bs)
{
Console.WriteLine(x.Name);
Console.ReadLine();
}
}
}
}
In Storage Account of pool Container:
Now inside test Folder:
Output:
Press Enter after every line to get File names one by one.