[英]How to delete Azure blob from asp.net web api?
将图像从我的Web api上传到azure blob存储可以正常工作,但是在尝试删除它们时却出现以下错误:“ Microsoft.WindowsAzure.Storage.dll中发生了'Microsoft.WindowsAzure.Storage.StorageException类型的异常,但是用户代码未处理”
这是我使用的代码:
// Retrieve storage account from connection string.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
// Retrieve reference to a blob named "myblob.txt".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob.txt");
// Delete the blob.
blockBlob.Delete();
我试图使用的代码来自: https : //azure.microsoft.com/sv-se/documentation/articles/storage-dotnet-how-to-use-blobs/#delete-blobs
任何帮助或输入表示高度赞赏,谢谢!
您应该确保正确的文件名或容器名。 我同时使用这两种方法。我确信这两种方法都可以。
您可以在下面的行中尝试代码吗?
var result= blockBlob.DeleteIfExists();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.