Azure Blob文件名中的模式搜索 [英] Pattern search in Azure blob file names

查看:75
本文介绍了Azure Blob文件名中的模式搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试搜索与我的搜索模式匹配的文件. /span>

I am trying to search files that match my search pattern.

static void ListBlobsInFolder() {
            var account = <MyStorageAccount>
            var blobClient = account.CreateCloudBlobClient();
            var containerName = "importcontainer";
            var folderName = "subfolder";
            var container = blobClient.GetContainerReference(containerName);
            var query = container.ListBlobs(prefix: folderName, useFlatBlobListing: true, blobListingDetails: BlobListingDetails.None);
            foreach(var item in query) {
                Console.WriteLine(item.Uri.Segments.Last());
            }
        }



This gets me the list of files present in the subfolder.

有没有一种方法可以返回仅与模式匹配的文件.示例我想检索包含"abc"的文件名.在里面.

Is there a way to return the files that only match a pattern. Example I want to retrieve file names that contains "abc" in it.

在Azure中有可能吗?

Is this possible in Azure ?

推荐答案

唐加,

您应该能够使用LINQ查询来获取具有特定模式的文件的结果.您可以使用布尔方法Contains("abc").例如:

You should be able to use a LINQ query for getting the results of files with a specific pattern. You can use boolean method Contains("abc").  For example:

if(item.Uri.Segments.Last().Contains("abc"))
{
    Console.WriteLine(item);
}

有关如何使用此方法的更多详细信息,我建议使用以下LINQ参考指南:

For further details on how you can use this method, I would recommend the following LINQ reference guide: https://docs.microsoft.com/en-us/dotnet/api/system.linq.enumerable.contains?view=netframework-4.7.2

如果此答案有帮助,请单击标记为答案"或向上投票.要提供有关您的论坛体验的其他反馈,请单击 此处

If this answer was helpful, click "Mark as Answer" or Up-Vote. To provide additional feedback on your forum experience, click Here



这篇关于Azure Blob文件名中的模式搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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