问题描述
我正在尝试搜索与我的搜索模式匹配的文件. /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, clickHere
这篇关于Azure Blob文件名中的模式搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!