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

Pur*_*ome 0 c# azure azure-storage

我正试图弄清楚如何

  • 列出单个目录下的所有目录

-要么-

  • 列出单个目录中的所有文件

使用Azure存储客户端库for .NET.

MS文档确实给我们的API端点打 ......但我希望使用.NET存储SDK它处理了很多低级别的通信(认证等),对我来说.

有谁能告诉我这是做什么的,拜托?

Tam*_*oft 5

查看我们的文件存储示例,了解一些代码,了解如何执行此操作.

片段:

//***** 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.");
Run Code Online (Sandbox Code Playgroud)