场景:程序可以查看存储帐户并处理所有新的和修改的文件,并在有任何新文件时采取行动。为此,我想找到最新文件的最后修改日期。我怎样才能实现这一点?任何人请帮助我。
namespace ListStorageAccntFiles
{
class Program
{
static void Main(string[] args)
{
Console.Clear();
CloudStorageAccount StorageAccount =
CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
var BlobClient = StorageAccount.CreateCloudBlobClient();
var Container = BlobClient.GetContainerReference("samples‐workitems");
//Code to list the blobnames in Console
var list = Container.ListBlobs();
List<string> blobNames = list.OfType<CloudBlockBlob>().Select(b =>b.Name).ToList();
blobNames.ForEach(Console.WriteLine);
//Code for the remaining
}
}
}
最佳答案
终于得到答案了(只是所有文件的最后修改日期,而不是具体的最新文件)。
//Code to get the last modified date
CloudBlockBlob blockBlob = Container.GetBlockBlobReference(blobName);
blockBlob.FetchAttributes();
var lastModifiedDate = blockBlob.Properties.LastModified;
Console.WriteLine(lastModifiedDate);
关于c# - 获取存储帐户中最新文件的上次修改日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39137934/