简体   繁体   English

如何使用C#从Azure存储下载所有文件?

[英]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.

相关问题 azure storage / c#:从容器中的目录下载所有文件 - azure storage / c#: Download all files from a directory in a container 如何使用 c# 从 Azure Blob 存储的单个请求中下载多个文件? - How to download multiple files in a single request from Azure Blob Storage using c#? 如何使用C#从Azure容器/ Blob中读取/下载所有文件? - How to read/Download all files from a Azure container/Blob using C#? 如何从 C# 核心中的 azure blob 存储读取所有文件 - How read all files from azure blob storage in C# Core 使用c#从azure文件存储中递归获取文件 - Get files recursively from azure file storage using c# 使用 Azure SAS URL 从 Azure Blob 存储将 Blob(所有文件)下载到浏览器中 - Using Azure SAS URL download Blob (all files) once from Azure Blob Storage into Browser 如何使用下载链接从 Azure Blob 存储下载文件 - How to download files from Azure Blob Storage with a Download Link 如何使用C#从Azure存储容器还原数据库 - How to restore database from azure storage container using c# 如何使用Azure WebJob将文件上载到Azure Blob存储? (使用C#,.NET) - How to upload files to Azure Blob Storage using Azure WebJob? (Using C#, .NET) 如何使用 C# 中的 Azure.Storage.Blobs 以 ByteArray 格式从 Azure 存储 blob 中获取文件 - How to get file from Azure storage blob in a ByteArray format using Azure.Storage.Blobs in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM