Reputation: 60871
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
Upvotes: 0
Views: 921
Reputation: 4199
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
Upvotes: 2