1
如何使用C#語言知道Azure中容器的大小。我有幾百TB的文件,所以我不會遞歸地工作。我試着用下面的代碼。如何知道Windows Azure中一個容器的C#大小?
var key = Util.GetPassword("Storage Account Key");
var accountName = "mystorageaccount";
var connectionString = "DefaultEndpointsProtocol=https;AccountName="
+ accountName + ";AccountKey=" + key;
var account = CloudStorageAccount.Parse(connectionString);
var blobClient = account.CreateCloudBlobClient();
var blobContainer = blobClient.GetContainerReference("mycontainer");
long fileSize = 0;
foreach (CloudBlockBlob blobItem in blobContainer.ListBlobs())
{
fileSize += blobItem.Properties.Length;
}
fileSize.Dump();
剛一說明,如果斑點數很高,最好是使用BlobContinuationToken實現分頁代碼。否則上面的代碼將超時。 – Hanno