2010-11-11 54 views

回答

15

这是很容易:

string text = CloudStorageAccount.Parse("<your connection string>").CreateCloudBlobClient().GetBlobReference("path/to/the/blob.txt").DownloadText(); 

当然,如果斑在一个公开的容器,你可以这样做:

string text = new WebClient().DownloadString("http://youraccount.blob.core.windows.net/path/to/blob.txt"); 
+0

我没有访问'GetBlobReference( “String”)'而不是'我有'GetBlobReferenceFromServer()'我忘记了什么? – jdave 2016-04-21 16:29:11

+0

这个答案是从2010年开始的。如果方法名称在中间年份发生了变化,我不会感到惊讶。 – smarx 2016-04-21 16:55:00

2
// connect to development storage. To connect to azure storage use connection string 
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount; 
CloudBlobClient client = storageAccount.CreateCloudBlobClient(); 

// if you know the blob you want to access you can do this: 
CloudBlob blob = client.GetBlobReference("containername/blobname.txt"); 

// To display text in console: 
Console.WriteLine(blob.DownloadText()); 
Console.ReadKey();