How do we track azure file storage folder is updated or not?

江枫思渺然 提交于 2019-12-06 07:17:30

To retrieve property values, call the FetchAttributesAsync method on your blob or container to populate the properties, then read the values.

When you run your console app, it essentially creates a new instance of CloudFileShare object and its properties are initialized to the default value. You would need to call FetchAttributes method on this to fill the properties.

Also, when you list the file's the properties of the file are fetched as well, you will not need to create a new instance of CloudFileShare. You could refer to this thread.

You could use sourceName.FetchAttributes(); before retrieve property. I test it and it works fine. Please refer to the code as below:

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;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!