コード例 #1
0
        /// <summary>
        /// Lists blobs beginning with the specified prefix, which must include the container name.
        /// Note that the ListBlobs method is called synchronously, for the purposes of the sample. However, in a real-world
        /// application using the async/await pattern, best practices recommend using asynchronous methods consistently.
        /// </summary>
        /// <param name="blobClient">The Blob service client.</param>
        /// <param name="prefix">The prefix.</param>
        private static void ListBlobsFromServiceClient(CloudBlobClient blobClient, string prefix)
        {
            Console.WriteLine("List blobs by prefix. Prefix must include container name:");

            try
            {
                // The prefix is required when listing blobs from the service client. The prefix must include
                // the container name.
                foreach (var blob in  blobClient.ListBlobs(prefix, true, BlobListingDetails.None, null, null))
                {
                    Console.WriteLine("\tBlob:" + blob.Uri);
                }

                Console.WriteLine();
            }
            catch (StorageException e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
                throw;
            }
        }