我们如何跟踪azure文件存储文件夹是否更新?

我有azure色的文件存储,里面有其他文件夹。 我想检查或跟踪该文件夹的上次更新时间?

我做了一个简单的控制台应用程序来获取该位置的所有文件 –

// Get list of all files/directories on the file share CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["storageConnectionString"]); CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient(); CloudFileShare fileShare = fileClient.GetShareReference(ConfigurationManager.AppSettings["shareName"]); var sourceName = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings["sourceName"])); IEnumerable fileList = sourceName.ListFilesAndDirectories(); CloudFileDirectory destinationDir = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings["destinationName"])); foreach (IListFileItem listItem in fileList) { // gives me all file records } 

我试着像这样得到它,但它是nullvar test = sourceName.Properties.LastModified;

因为null我无法使用此查询:(

  var latest= fileShare.GetRootDirectoryReference().ListFilesAndDirectories() .OfType() .OrderByDescending(m => m.Properties.LastModified) .ToList() .First(); 

我刚刚注意到,我刚刚将一个新文件上传到该文件夹​​,但LastModified仍然是旧日期,这意味着LastModified与该文件夹和文件是分开的:O现在该怎么办?

我想检查是否有任何新文件在24小时内更新到主文件夹的任何子文件夹中。

我想知道如何从该源文件夹中检查上次更新的文件日期时间?

为什么LastModified为null?

要检索属性值 ,请在blob或容器上调用FetchAttributesAsync方法以填充属性,然后读取值。

当您运行控制台应用程序时,它实际上会创建一个新的CloudFileShare对象实例,并将其属性初始化为默认值。 您需要在此上调用FetchAttributes方法来填充属性。

此外,当您列出文件时,也会获取文件的属性,您不需要创建CloudFileShare的新实例。 你可以参考这个post 。

你可以使用sourceName.FetchAttributes(); 在检索财产之前。 我测试它,它工作正常。 请参考以下代码:

 CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["storageConnectionString"]); CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient(); CloudFileShare fileShare = fileClient.GetShareReference(ConfigurationManager.AppSettings["shareName"]); var sourceName = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings["sourceName"])); sourceName.FetchAttributes(); var test = sourceName.Properties.LastModified;