无法使用 C# 读取 Azure 存储容器中可用的所有文件夹和文件?

Not able to read all folders & files available in azure storage container using c#?

我正在使用以下代码读取 azure 中可用的所有文件:

private const string account = "Testaccount";
private const string key = "I1yMjhk1Pp10KBxU4mnuaxXnsupk3USn8B85TtSunXzO+WLZ+uYbFl/mCkD8Q7yqAA==";
 private const string url = "http://Testaa.blob.core.windows.net/contractattachments/201503/20150302110215315197/20150331114910310626/Test%20-%20Copy%20-%20file.txt";
 private const string containerName = "TestFiles";
 private const string blobName = "File1";

        static void Main(string[] args)
        {

            // get storage
            StorageCredentialsAccountAndKey creds = new StorageCredentialsAccountAndKey(account, key);
            CloudBlobClient blobStorage = new CloudBlobClient(url, creds);

             //get blob container
            CloudBlobContainer blobContainer = blobStorage.GetContainerReference(containerName);


            BlobContainerPermissions permissions = new BlobContainerPermissions();
            permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
            blobContainer.SetPermissions(permissions);  


             //get blob data
            CloudBlob cloudBlob = blobContainer.GetBlobReference(blobName);
            //string text = cloudBlob.DownloadText();

            // print text
           // Console.WriteLine(text);


            //List blobs and directories in this container
            var blobs = blobContainer.ListBlobs();
            List<string> listofblobs=new List<string>();

            foreach (var blobItem in blobs)// Exception ----The requested URI does not represent any resource on the server.
            {
              blobItem.Container.GetPermissions();

            }

            foreach (var blobItem in blobs)
            {

                string BolbName = blobItem.Container.Name.ToString();

                Console.WriteLine(blobItem.Uri);
            }


        }

> Actually We have above mentioned storage account and there are containers in that account. Again container contains sub folders and sub folder contains ..some files .....so my requirement is to read all files from available all container ... So first of i was trying to read all files from one container ..but its giving me exception as below The requested URI does not represent any resource on the server. Please help me.....Let me know if i am missing anything ...

  1. url 未指向 Azure Blob 服务帐户,即使它已传递给 CloudBlobClient's constructor. Please consider using CloudStorageAccount instead and instantiate CloudBlobClient using CreateCloudBlobClient
  2. StorageCredentialsAccountAndKey 已在 Azure 存储客户端库 2.0 中删除,因此您使用的是非常旧的版本。请考虑升级到最新版本以获得性能改进和错误修复。