简体   繁体   English

如何使用 .NET 存储 SDK 列出 Azure 文件存储中根目录中的所有目录或文件?

[英]How to list all the Directories or Files, from a root Directory, in Azure File Storage -and- using the .NET Storage SDK?

I'm trying to figure out how to我想弄清楚如何

  • list all the directories under a single directory列出单个目录下的所有目录

-or- -或者-

  • list all the files in a single directory列出单个目录中的所有文件

using the Azure Storage Client Library for .NET .使用适用于 .NETAzure 存储客户端库

The MS docs do give us an API endpoint to hit ... but I'm hoping to use the .NET Storage SDK which handles a lot of the low level communications (authentication, etc) for me.MS 文档确实为我们提供了一个 API 端点以供使用……但我希望使用 .NET Storage SDK 来为我处理许多低级通信(身份验证等)。

Can anyone show me what it takes to do this, please?任何人都可以告诉我这样做需要什么吗?

Please take a look at our File storage sample for some code that shows how to do this.查看我们的文件存储示例以获取一些显示如何执行此操作的代码。

Snippet:片段:

//***** Get list of all files/directories on the file share*****//

// List all files/directories under the root directory.
Console.WriteLine("Getting list of all files/directories under the root directory of the share.");

IEnumerable<IListFileItem> fileList = cloudFileShare.GetRootDirectoryReference().ListFilesAndDirectories();

// Print all files/directories listed above.
foreach (IListFileItem listItem in fileList)
{
    // listItem type will be CloudFile or CloudFileDirectory.
    Console.WriteLine("    - {0} (type: {1})", listItem.Uri, listItem.GetType());
}

Console.WriteLine("Getting list of all files/directories in the file directory on the share.");
var directories = fileDirectory.ListFilesAndDirectories().Where(x => x.GetType() == 
typeof(CloudFileDirectory)).Cast<CloudFileDirectory>();

var files = fileDirectory.ListFilesAndDirectories().Where(x => x.GetType() == 
typeof(CloudFile)).Cast<CloudFile>().ToList();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 azure .net SDK 或 Fluent ZDB974238714CA8DE64FZACE1D8037 - List all file share from storage account using azure .net SDK or Fluent API? 如何使用适用于.NET的Azure存储客户端库(BLOBS)列出所有虚拟目录和子目录 - How to list all virtual directories and subdirectories using Azure Storage Client Library for .NET (BLOBS) 如何使用C#从Azure存储下载所有文件? - How to download all files from Azure Storage using C#? .NET Azure Blob 存储:获取不列出所有 Blob 的根级目录 - .NET Azure Blob Storage: Get Root-Level Directories w/o Listing All Blobs Azure文件存储SMB很慢,无法列出目录中的文件 - Azure file Storage SMB slow to list files in directory 使用C#将文件上传到Azure文件存储中后,目录0中其他所有文件的长度为 - Uploading a file to azure file storage using C# makes all the rest of the files in the directory 0 length azure storage / c#:从容器中的目录下载所有文件 - azure storage / c#: Download all files from a directory in a container 如何使用 Azure 存储 SDK 将 Azure 文件存储上的文件从一个子文件夹移动到另一个子文件夹? - How to move a file on Azure File Storage from one sub folder to another sub folder using the Azure Storage SDK? 如何使用.net SDK(C#)创建Azure搜索索引器以从Azure Blob存储中提取数据 - How to create an Azure Search Indexer using .net SDK (c#) to pull data from Azure blob storage 如何删除 Azure 文件存储文件夹中的所有文件? - How do I delete all files in an Azure File Storage folder?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM