我有代碼將容器的 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 關注
- 184 瀏覽
添加回答
舉報
0/150
提交
取消