c# - 获取存储帐户中最新文件的上次修改日期

标签 c# azure azure-storage azure-blob-storage

场景:程序可以查看存储帐户并处理所有新的和修改的文件,并在有任何新文件时采取行动。为此,我想找到最新文件的最后修改日期。我怎样才能实现这一点?任何人请帮助我。

namespace ListStorageAccntFiles
{
   class Program
   {
      static void Main(string[] args)
      {
        Console.Clear();

        CloudStorageAccount StorageAccount =
        CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        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();

       blobNames.ForEach(Console.WriteLine);
       //Code for the remaining

    }
  }
}

最佳答案

终于得到答案了(只是所有文件的最后修改日期,而不是具体的最新文件)。

//Code to get the last modified date

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

关于c# - 获取存储帐户中最新文件的上次修改日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39137934/

相关文章:

c# - 如何拆分文件名和扩展名

azure - 如何在Azure中检查创建的存储帐户V2是否具有数据湖gen2属性?

c# - 如果图片可以从 10x10 到 500x500,如何在 PictureBox 中显示图像

Azure Web 应用程序 - 列表和 Web 应用程序 - 列表函数 Rest API 响应为空

c# - 在 Azure Web 角色中动态托管多个网站

azure - Spring Boot Azure AD - AzureADGraphClient.aquireTokenForGraphApi 抛出错误 : unable to acquire on-behalf-of token for client

c++ - 在 C++ 中使用 wastorage 将 uint8_t 数组上传到 azure blob 存储的最佳方法

c# - 这是简化继承类的有效方法吗?

c# - 我如何使用 C# 子字符串获得没有最后 4 个字符的名称?

c# - ASP.NET 身份用户存储 : Why return Task?