我有代码将容器的 blob 和文件夹列出到 asp.net listBox。双击作为文件夹的列表项时,文件夹的内容将转到列表框。问题是,这不适用于第一层之后的任何文件夹,并且列表框变为空。我的论点是,我的代码所引用的目录位于容器内,并且由于子文件夹不直接位于容器内,因此无法识别它并且列表框显示为空。 protected void Page_Load(object sender, EventArgs e) { if (Request["__EVENTARGUMENT"] != null && Request["__EVENTARGUMENT"] == "expand") { List<string> ListBlobsInFolder() { List<string> blobs = new List<string>(); CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse("MYCONNECTIONSTRING"); CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient(); CloudBlobContainer container = cloudBlobClient.GetContainerReference("testcontainer"); ListItem listItem = lboxLogs.SelectedItem; CloudBlobDirectory directory = container.GetDirectoryReference(listItem.ToString()); IEnumerable<IListBlobItem> blobList = directory.ListBlobs(); foreach (IListBlobItem item in blobList) { blobs.Add(string.Format("{0}", item.Uri.Segments.Last())); } return blobs; //IEnumerable<IListBlobItem> subDirectoryList = subDirectory.ListBlobs(); }我不确定如何解决这个问题,这样当我双击时,目录引用将在必要时来自容器内,并在必要时在另一个文件夹内。
1 回答

慕容森
TA贡献1853条经验 获得超18个赞
当涉及到 Azure blob 的文件夹结构时,它目前是一个虚拟文件夹,访问这些虚拟文件夹中的任何内容的方式是将虚拟目录的名称附加到其中的 blob,例如:
['Virtual-Folder/2019-02-06 10_43_04-Access Control - Microsoft Azure.png', 'Virtual-Folder/Boards.png', 'storage2.gif']
列出包含名为“Virtual-Folder”的虚拟文件夹的容器内的 Blob 列表时,如果我尝试仅调用“,则可以通过此名称访问其中的 Blob:“‘Virtual-Folder/Boards.png’” Boards.png”它将不起作用。
- 1 回答
- 0 关注
- 165 浏览
添加回答
举报
0/150
提交
取消