According to MSDN for CloudBloblContainer.ListBlobs() :
The types of objects returned by the ListBlobs method depend on the type of listing that is being performed. If the UseFlatBlobListing property is set to true, the listing will return an enumerable collection of CloudBlob objects. If UseFlatBlobListing is set to false (the default value), the listing may return a collection containing CloudBlob objects and CloudBlobDirectory objects. The latter case provides a convenience for subsequent enumerations over a virtual blob hierarchy.
So, if you want only blobs, you should set the UseFlatBlobListing property UseFlatBlobListing to true.
var storageAccount = CloudStorageAccount.Parse(conn); var blobClient = storageAccount.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(containerName); // ** new code below ** // BlobRequestOptions options = new BlobRequestOptions(); options.UseFlatBlobListing = true; // ** new code above ** // var blobs = container.ListBlobs(options); // <-- add the parameter to overload foreach (var blob in blobs) { Console.WriteLine(blob.GetType().ToString()); }
Bob. source share