How do we get the path to a specific blob without the container name?
You can list blobs like so:
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();
You can then iterate each one:
foreach (var blob in blobs)
{
var filepath = string.Join("/", blob.Uri.LocalPath.Split('/').Skip(2));
//dostuff
}
Instead of having to do this ugly string.Join("/", blob.Uri.LocalPath.Split('/').Skip(2))
join/split, can we get the path ( minus the container name ) in a simpler way such as blob.Path() or something?
Example: storageAccount\\myContainer\\some\\path\\file.jpg
Expected Result : \\some\\path\\file.jpg
You can just do blob.Name
to get the full path of the blob.
foreach (var blob in blobs)
{
var filepath = blob.Name;
}
Example:
My output was this New Directory/test.svg
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.