CloudBlobDirectory.GetSubdirectory 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 blob subdirectory within this blob directory.

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

Usage

Visual Basic
Dim instance As CloudBlobDirectory
Dim itemName As String
Dim returnValue As CloudBlobDirectory

returnValue = instance.GetSubdirectory(itemName)

Syntax

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

Parameters

itemName

The name of the blob subdirectory.

Return Value

A CloudBlobDirectory object representing the blob subdirectory.

Example

The following code example gets a subdirectory of a blob directory, then enumerates the blobs in the subdirectory.

 Copy Code
static void GetVirtualSubdirectory(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.
    CloudBlobDirectory blobDir = blobClient.GetBlobDirectoryReference("myvirtualdir/a/");

    //Get a reference to a subdirectory in this directory.
    CloudBlobDirectory subDir = blobDir.GetSubdirectory("b/");

    //Enumerate the blobs in the subdirectory.
    foreach (var blobItem in subDir.ListBlobs())
    {
        Console.WriteLine("Blob: " + blobItem.Uri);
        Console.WriteLine("Blob parent: " + blobItem.Parent.Uri);
        Console.WriteLine("Blob container: " + blobItem.Container.Name);
        Console.WriteLine();
    }
}

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