![](/img/trans.png)
[英]Get a reference of Azure blob by the full Uri not the blob name?
[英]how to get full name to blob
我們如何獲取沒有容器名稱的特定Blob的路徑?
您可以像這樣列出blob:
var query = await @in.ListBlobsSegmentedAsync(string.Empty, true, BlobListingDetails.None, int.MaxValue, null, null, null);
var blobs = query.Results.OfType<CloudBlockBlob>()
.OrderByDescending(m => m.Properties.LastModified)
.Take(msg.Quantity)
.ToList();
然后,您可以迭代每個對象:
foreach (var blob in blobs)
{
var filepath = string.Join("/", blob.Uri.LocalPath.Split('/').Skip(2));
//dostuff
}
不必執行此丑陋的string.Join("/", blob.Uri.LocalPath.Split('/').Skip(2))
/ split,我們可以獲取路徑( 減去容器名稱 )更簡單的方法,例如blob.Path()或其他東西?
示例: storageAccount \\ myContainer \\ some \\ path \\ file.jpg
預期結果 : \\some\\path\\file.jpg
您可以只執行blob.Name
來獲取blob的完整路徑。
foreach (var blob in blobs)
{
var filepath = blob.Name;
}
例:
我的輸出是這個New Directory/test.svg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.