[英]How to download all files from Azure Storage using C#?
I am new bee to Azure Storage . 我是Azure Storage的新手 。 So, please consider my content in post. 因此,请考虑我在帖子中的内容。 I have a Azure Storag
e account on which we have all files stored
. 我有一个Azure Storag
帐户,上面all files stored
。 Now, i want to download
all these files
to a folder by looping through each directory and sub directory of the Azure Storage
. 现在,我想folder by looping through each directory and sub directory of the Azure Storage
download
所有这些files
download
到一个folder by looping through each directory and sub directory of the Azure Storage
。
Sample code: 样例代码:
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "photo1.jpg".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("photo1.jpg");
// Save blob contents to a file.
using (var fileStream = System.IO.File.OpenWrite(@"path\myfile"))
{
blockBlob.DownloadToStream(fileStream);
}
But i am not able to get all the 'Container' and its contents with subcontents. 但是我无法获得所有“容器”及其包含子内容的内容。
Help Appreciated! 帮助赞赏!
Use blobClient. 使用blobClient。 ListContainers () to get all containers, and use container. ListContainers ()获取所有容器,并使用容器。 ListBlobs () to get all blobs in a container. ListBlobs ()获取容器中的所有blob。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.