0

我正在尝试从 Azure blob 下载文件并将其保存在本地,但似乎失败了。以下是相关代码:

    var blobClientCode = client.CreateCloudBlobClient();
    string codeUri = "https://???.blob.core.windows.net/...../mycode.exe";
    using (var codeContent = File.OpenWrite("C:\\code.exe")) {
        blobClientCode.GetBlockBlobReference(codeUri).DownloadToStream(codeContent);
    }

我收到容器不存在的错误。我究竟做错了什么?

4

1 回答 1

0

尝试首先获取对容器的引用,然后仅使用相对路径从中定义 CloudBlockBlob。

这是对我有用的代码:

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("myContainerName");

CloudBlockBlob blockBlob = container.GetBlockBlobReference("/subfolder/filename.exe");
using (fileStream == System.IO.File.OpenWrite("C:\code.exe")) {
    blockBlob.DownloadToStream(fileStream);
}
于 2013-04-13T21:46:22.623 回答