SPRZEDAŻ: 1-800-867-1389
EN
Ta zawartość nie jest dostępna w wymaganym języku. Wersja w języku angielskim znajduje się tutaj.

CloudBlobClient.GetBlobDirectoryReference Method

Updated: April 24, 2011

[This topic is part of the Windows Azure Storage Client Library 1.7, which has been deprecated. The current recommended version is Storage Client Library 3.0.]

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

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

'Użycie

public CloudBlobDirectory GetBlobDirectoryReference (
	string blobDirectoryAddress
)

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.

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.

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);
    }
}


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.


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

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

Czy oceniasz te materiały jako pomocne?
(Pozostało znaków: 1500)
Dziękujemy za opinię.
Pokaż:
© 2014 Microsoft