Microsoft Azure: How to create sub directory in a blob container

前端 未结 9 1741
清酒与你
清酒与你 2020-11-27 16:01

How to create a sub directory in a blob container

for example,

in my blob container http://veda.blob.core.windows.net/document/

If I store some files it

9条回答
  •  再見小時候
    2020-11-27 16:25

    There is a comment by @afr0 asking how to filter on folders..

    There is two ways using the GetDirectoryReference or looping through a containers blobs and checking the type. The code below is in C#

    CloudBlobContainer container = blobClient.GetContainerReference("photos");
    
    //Method 1. grab a folder reference directly from the container
    CloudBlobDirectory folder = container.GetDirectoryReference("directoryName");
    
    //Method 2. Loop over container and grab folders.
    foreach (IListBlobItem item in container.ListBlobs(null, false))
    {
        if (item.GetType() == typeof(CloudBlobDirectory))
        {
            // we know this is a sub directory now
            CloudBlobDirectory subFolder = (CloudBlobDirectory)item;
    
            Console.WriteLine("Directory: {0}", subFolder.Uri);
        }
    }
    

    read this for more in depth coverage: http://www.codeproject.com/Articles/297052/Azure-Storage-Blobs-Service-Working-with-Directori

提交回复
热议问题