title: Using Subdirectories in Windows Azure Blob Storage
body: <p>I am trying to upload a file to Windows Azure blob storage. From my understanding, you can upload files into something similar to a subdirectory. I want to upload a file to a blob such that the file essentially resides in <code>/TestContainer/subDirectory1/subDirectory2/file.png</code></p>
  
  <pre><code>// Setup the Windows Aure blob client
  CloudStorageAccount storageAccount = CloudStorageAccount.FromConfigurationSetting("BlobStorage");
  CloudBlobClient client = storageAccount.CreateCloudBlobClient();
  
  // Retrieve the TestContainer container from blob storage
  CloudBlobContainer container = client.GetContainerReference("TestContainer");
  if (container.CreateIfNotExist())
    container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
  
  // Setup the blob
  CloudBlob blob = container.GetBlobReference("");
  
  // Create the meta data for the blob
  NameValueCollection metadata = new NameValueCollection();
  metadata["id"] = fileID.ToString();
  blob.Metadata.Add(metadata);
  
  // Store the blob 
  byte[] bytes = GetFileBytes();
  blob.UploadByteArray(bytes);
  </code></pre>
  
  <p>How do I upload a file with a directory structure? The link <a href="http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/" rel="noreferrer">here</a> mentions there's a way to do it. However, it doesn't show you how to do it.</p>
  
  <p>Thank you!</p>