public static async Task <string> DownloadTextAsync(CloudBlob blob, Encoding encoding, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { using (MemoryStream stream = new MemoryStream()) { await blob.DownloadToStreamAsync(stream, accessCondition, options, operationContext); byte[] buffer = stream.ToArray(); return(encoding.GetString(buffer, 0, buffer.Length)); } }
public static string DownloadTextTask(CloudBlob blob, Encoding encoding, AccessCondition accessCondition = null, BlobRequestOptions options = null, OperationContext operationContext = null) { using (MemoryStream stream = new MemoryStream()) { try { blob.DownloadToStreamAsync(stream, accessCondition, options, operationContext).Wait(); } catch (AggregateException ex) { if (ex.InnerException != null) { throw ex.InnerException; } throw; } return(encoding.GetString(stream.ToArray())); } }