Getting null value for Azure blob last modified property

孤街浪徒 提交于 2019-12-01 11:55:06

Reason you're getting this behavior is because when you execute following line of code:

CloudBlockBlob blockBlob = container.GetBlockBlobReference(blob.ToString());

It essentially creates a new instance of CloudBlockBlob object and it's 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 blobs the properties of the blob are fetched as well. So you need not create a new instance of CloudBlockBlob. Simply use the blob object you got as listing result and use the properties from there. So your code would be:

        foreach (var blob in blobs)
        {
            var timemodified = blob.Properties.LastModified;
        }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!