簡體   English   中英

如何使用C#從Azure存儲下載所有文件?

[英]How to download all files from Azure Storage using C#?

我是Azure Storage的新手 因此,請考慮我在帖子中的內容。 我有一個Azure Storag帳戶,上面all files stored 現在,我想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

樣例代碼:

// 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);
} 

但是我無法獲得所有“容器”及其包含子內容的內容。

幫助贊賞!

使用blobClient。 ListContainers ()獲取所有容器,並使用容器。 ListBlobs ()獲取容器中的所有blob。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM