Akash.P Akash.P - 11 months ago 46
C# Question

Get last modified date of latest file in a storage account

Scenario:program that can look at storage account and process all new & modified files and take an action if there is any new ones. For that i want to find the last modified date of the latest file .How can i achieve this?Anyone please help me.

namespace ListStorageAccntFiles
class Program
static void Main(string[] args)

CloudStorageAccount StorageAccount =
var BlobClient = StorageAccount.CreateCloudBlobClient();
var Container = BlobClient.GetContainerReference("samples‐workitems");

//Code to list the blobnames in Console
var list = Container.ListBlobs();
List<string> blobNames = list.OfType<CloudBlockBlob>().Select(b =>b.Name).ToList();

//Code for the remaining


Answer Source

Finally got the answer(simply last modified date of all files,not the specific latest file).

//Code to get the last modified date

CloudBlockBlob blockBlob = Container.GetBlockBlobReference(blobName);
var lastModifiedDate = blockBlob.Properties.LastModified;