public byte[] GetFileAsBytes(IStoredFile storedFile) { var storageAccount = CloudStorageAccount.Parse(ConnectionString); var blobClient = storageAccount.CreateCloudBlobClient(); var blobContainer = blobClient.GetContainerReference(BlobContainer); var blockBlob = blobContainer.GetBlockBlobReference(Path.Combine(storedFile.StoredFilePath, storedFile.StoredFileName)); blockBlob.FetchAttributes(); var fileByteLength = blockBlob.Properties.Length; var fileContent = new byte[fileByteLength]; for (var i = 0; i < fileByteLength; i++) { fileContent[i] = 0x20; } blockBlob.DownloadToByteArray(fileContent, 0); return(fileContent); }
public byte[] GetFileAsBytes(IStoredFile storedFile) { var path = Path.Combine(GetAbsoluteRootStoragePath(), storedFile.StoredFilePath, storedFile.StoredFileName); return(File.ReadAllBytes(path)); }