假设我json每天在blob存储中生成几个文件.我想要做的是在我的任何目录中修改最新的文件.所以我的blob中有这样的东西:
2016/01/02/test.json
2016/01/02/test2.json
2016/02/03/test.json
Run Code Online (Sandbox Code Playgroud)
我想得到2016/02/03/test.json.因此,一种方法是获取文件的完整路径并进行正则表达式检查以查找创建的最新目录,但如果josn每个目录中有多个文件,则这不起作用.有没有什么File.GetLastWriteTime比得到最新的修改文件?我正在使用这些代码获取所有文件btw:
public static CloudBlobContainer GetBlobContainer(string accountName, string accountKey, string containerName)
{
CloudStorageAccount storageAccount = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
// blob client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// container
CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
return blobContainer;
}
public static IEnumerable<IListBlobItem> GetBlobItems(CloudBlobContainer container)
{
IEnumerable<IListBlobItem> items = container.ListBlobs(useFlatBlobListing: true);
return items;
}
public static List<string> GetAllBlobFiles(IEnumerable<IListBlobItem> blobs)
{
var listOfFileNames = new List<string>();
foreach (var blob in blobs)
{
var blobFileName …Run Code Online (Sandbox Code Playgroud) c# azure azure-storage-blobs azure-sdk-.net azure-blob-storage
private readonly CloudBlobContainer _blobContainer;
public void Remove()
{
if (_blobContainer.Exists())
{
_blobContainer.Delete();
}
}
Run Code Online (Sandbox Code Playgroud)
如何删除整个容器而不是容器中的一些List<string> disks容器?