之前写过一个往Microsoft Azure Storage Explorer里存储的功能,现在又要把东西给下载下来。
记录一下:
1 public string DownFileFromAzure() 2 { 3 StorageCredentials storageCredentials = new StorageCredentials(System.Configuration.ConfigurationManager.AppSettings["Blob_AccountName"].ToString(), System.Configuration.ConfigurationManager.AppSettings["Blob_AccountKey"].ToString()); 4 CloudStorageAccount storageAccount = new CloudStorageAccount(storageCredentials, "core.chinacloudapi.cn", true); 5 CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 6 CloudBlobContainer blobContainer = blobClient.GetContainerReference("acsh");//容器 7 8 CloudBlockBlob blockBlobs = blobContainer.GetBlockBlobReference("2019/7/1/131JS0E5201907000005");//除了外层的容器外的全路径 9 string end= blockBlobs.DownloadText(); 10 byte[] ensbyte = new byte[100000000]; 11 blockBlobs.DownloadToByteArray(ensbyte, 0); 12 blockBlobs.DownloadToFile(@"E:\DownFromAzure\Open", FileMode.OpenOrCreate);//直接下载到本地的文件 13 //blockBlobs.Delete(); 14 15 return ""; 16 }
原文地址:https://www.cnblogs.com/ZkbFighting/p/11122257.html
时间: 2024-11-06 07:18:59