[英]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我想弄清楚如何
-or- -或者-
using the Azure Storage Client Library for .NET .使用适用于 .NET的Azure 存储客户端库。
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.