【问题标题】:Last Access Time of the Azure storage filesAzure 存储文件的上次访问时间
【发布时间】:2020-08-08 15:44:11
【问题描述】:

除了日志分析之外,还有其他方法可以确定 Azure 存储文件的上次访问时间。那么,有没有人遇到过这种情况,实现这一目标的最佳方法是什么?还是我太在意这个?

先谢谢你了。

【问题讨论】:

  • 只想说清楚,是“上次修改时间”还是“上次访问时间”?
  • @IvanYang - 我们正在查看上次访问时间
  • 您能否告诉我您如何从日志分析中确定“上次访问时间”?据我所知,blob 没有“上次访问时间”属性,您可以看到这个feedback

标签: azure-blob-storage lastaccesstime


【解决方案1】:

在 Azure 文件存储中,直到日期都无法知道上次打开/查看/访问的时间,但有可能了解上次修改的文件。如果您正在寻找它,这里有一个 C# 方式:

CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("<Your Connection string>");
CloudFileClient cloudFileClient = cloudStorageAccount.CreateCloudFileClient();
CloudFileShare cloudFileShare = cloudFileClient.GetShareReference("<Your File Share Name>");
IEnumerable<IListFileItem> fileShareItemsList = cloudFileShare.GetRootDirectoryReference().ListFilesAndDirectories();

foreach (IListFileItem listItem in fileShareItemsList)
{
  if (listItem is CloudFile) // Checking direct files under the root directory for now
  {
    CloudFile file = (CloudFile)listItem;
    file.FetchAttributes(); // this is mandatory to fetch modified time
    DateTime lastModifiedTime = file.Properties.LastModified; // Here's the time!
    // Use it in your logic..
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-19
    • 2017-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-05
    • 2016-05-04
    相关资源
    最近更新 更多