[英]Getting 404 not found when trying to delete Azure blob
I am getting a list of files hosted in Azure and attempting to delete them. 我正在获取Azure中托管的文件列表,并尝试删除它们。
var blobList = container.ListBlobs(prefix: "/2017/1/", useFlatBlobListing:true);
foreach (var blob in blobList)
{
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blob.Uri.ToString());
blockBlob.Delete(); // This line causes a 404 not found exception.
}
When I debug and step through the code the blob.Uri matches the folder structure in Azure so not sure why this exception occurs. 当我调试并逐步执行代码时,blob.Uri与Azure中的文件夹结构匹配,因此不确定为什么会发生此异常。
Edit: Found an answer - I have to check the type and box appropriately 编辑:找到了答案-我必须适当地检查类型和复选框
foreach (var item in blobList)
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob blob = (CloudBlockBlob)item;
blob.Delete();
}
}
The op wrote: 操作员写道:
Edit: Found an answer - I have to check the type and box appropriately 编辑:找到了答案-我必须适当地检查类型和复选框
foreach (var item in blobList) { if (item.GetType() == typeof(CloudBlockBlob)) { CloudBlockBlob blob = (CloudBlockBlob)item; blob.Delete(); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.