I'm porting code to work with Azure's Storage SDK in C#.
Traditionally, I'd call this to update modified the last write/modified time of a file:
File.SetLastWriteTimeUtc(fileName, lastWriteTimeUtc);
To update a blob's last modified time, I'm trying to do something like this but can't because LastModified is not accessible:
CloudBlockBlob blob = container.GetBlockBlobReference(fileName);
blob.Properties.LastModified = lastWriteTimeUtc;
blob.SetProperties();
Compiler error:
Property or indexer 'Microsoft.WindowsAzure.Storage.Blob.BlobProperties.LastModified' cannot be assigned to -- it is read only
How can I update the LastModified property? It won't always be updated to the current time, so I can't just reupload/touch the file.
Azure allows you to add METADATA to the containers and blobs. LastModified is an internal property and there is no point to let external parties update it - it should reflect its meaning.
In your case, it seems that you want to keep old values after migrating content, and content might not allow to add property inside. Say, it is an image.
In this case use Metadata to add and read additional properties. Article about Metadata on MSDN
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With