2021年3月9日星期二

CloudBlobDirectory' does not contain a definition for 'ListBlobs' and no accessible extension method 'ListBlobs' in .net core 3.1 upgrade

I am upgrading a .net45 app to .net core 3.1 and I have a piece of code there like below.

private void GetContainerDirectories(IEnumerable<IListBlobItem> blobList)          {              // First list all the actual FILES within              // the current blob list. No recursion needed:              foreach (var item in blobList.Where              ((blobItem, type) => blobItem is CloudBlockBlob))              {                  var blobFile = item as CloudBlockBlob;                  sb.Add(new Tree { Name = blobFile.Name, Id = blobFile.Name, ParentId = blobFile.Parent.Prefix, Title = Path.GetFileName(blobFile.Name), IsDirectory = false });              }                // List all additional subdirectories              // in the current directory, and call recursively:              foreach (var item in blobList.Where              ((blobItem, type) => blobItem is CloudBlobDirectory))              {                  var directory = item as CloudBlobDirectory;                  sb.Add(new Tree { Name = directory.Prefix, Id = directory.Prefix, ParentId = directory.Parent.Prefix, Title = new DirectoryInfo(directory.Prefix).Name, IsDirectory = true });                    // Call this method recursively to retrieve subdirectories within the current:                  GetContainerDirectories(directory.ListBlobs()); ***////////Here i am getting error***              }          }  

In the last line [ GetContainerDirectories(directory.ListBlobs()) ], I am getting error for ListBlobs and I am not able to find any useful solution for this. The error like this -
'CloudBlobDirectory' does not contain a definition for 'ListBlobs' and no accessible extension method 'ListBlobs' accepting a first argument of type 'CloudBlobDirectory' could be found (are you missing a using directive or an assembly reference?)

Has anyone any idea how to fix this ? Many thanks in advance :)

https://stackoverflow.com/questions/66530408/cloudblobdirectory-does-not-contain-a-definition-for-listblobs-and-no-accessi March 08, 2021 at 09:05PM

没有评论:

发表评论