CloudBlobClient.GetBlobDirectoryReference Method

Storage Client Library NET API

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Returns a reference to a CloudBlobDirectory object with the specified address.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Usage

Visual Basic
Dim instance As CloudBlobClient
Dim blobDirectoryAddress As String
Dim returnValue As CloudBlobDirectory

returnValue = instance.GetBlobDirectoryReference(blobDirectoryAddress)

Syntax

Visual Basic
Public Function GetBlobDirectoryReference ( _
	blobDirectoryAddress As String _
) As CloudBlobDirectory
C#
public CloudBlobDirectory GetBlobDirectoryReference (
	string blobDirectoryAddress
)
C++
public:
CloudBlobDirectory^ GetBlobDirectoryReference (
	String^ blobDirectoryAddress
)
J#
JScript

Parameters

blobDirectoryAddress

Type: System.String

The absolute URI to the directory, or a relative URI beginning with the container name.

Return Value

Type: Microsoft.WindowsAzure.StorageClient.CloudBlobDirectory

A reference to a blob directory.

Example

The following example gets a reference to a blob directory, then lists the blobs beneath it. The listing is carried out in two ways. In the first case, blobs are listed hierarchically. The result of the hierarchical listing contains only the blobs and blob directories that lie directly beneath the specified blob directory. A hierarchical listing is the default approach. The listing approach is determined by the value of the UseFlatBlobListing property; by default, this property is set to false.

In the second case, UseFlatBlobListing is explicitly set to true. A flat blob listing ignores the virtual hierarchy, so that all blobs beneath the blob directory are included in the listing.

C# Copy Code
static void ListBlobsInDirectory(Uri blobEndpoint, string accountName, string accountKey)
{
    //Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = 
        new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    //Get a reference to a blob directory in a container named 'mycontainer'.
    CloudBlobDirectory blobDir = blobClient.GetBlobDirectoryReference("mycontainer/a/b/");

    //List blobs and directories in this blob directory hierarchically.
    foreach (var blobItem in blobDir.ListBlobs())
    {
        Console.WriteLine(blobItem.Uri);
    }
    Console.WriteLine();

    //List blobs in this blob directory using a flat listing.
    BlobRequestOptions options = new BlobRequestOptions();
    options.UseFlatBlobListing = true;
    foreach (var blobItem in blobDir.ListBlobs(options))
    {
        Console.WriteLine(blobItem.Uri);
    }
}

Remarks

A blob directory simplifies working with a hierarchical organization of blobs. A blob directory is a blob name prefix that can be used to navigate a hierarchy. The prefix may end in a delimiter character, but a delimiter is not required; the directory can end in any character.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also