I want to get files from Azure Blob Storage that are modified everyday. We have a container in Azure which is filled by two Excel files every day, and I need to get those files.
So far, I'm only able to get one file using latestmodifiedon. How can I get both files?
private static DataSet GetExcelBlobData()
{
var containerName = "salesbycontract";
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Microsoft.Azure.CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
CloudBlockBlob blockbob = container.ListBlobs().OfType<CloudBlockBlob>().OrderByDescending(m => m.Properties.LastModified).ToList().First();
var x = blockbob.Name;
Console.WriteLine(x);
DataSet ds;
using (var memstream = new MemoryStream())
{
blockbob.DownloadToStream(memstream);
var excelReader = ExcelReaderFactory.CreateOpenXmlReader(memstream);
ds = excelReader.AsDataSet();
excelReader.Close();
}
return ds;
}