2015-06-30 50 views
1

將圖像從我的web api上傳到azure blob存儲工作正常,儘管試圖刪除它們時出現以下錯誤: 「Microsoft.WindowsAzure.Storage中發生了類型爲」Microsoft.WindowsAzure.Storage.StorageException「的異常。 DLL而不是在用戶代碼」如何從asp.net web api刪除Azure blob?

這是代碼即時通訊使用的處理:

// 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

任何幫助或輸入的高度讚賞,謝謝!

+0

也許你應該看看例外情況並嘗試解釋它。發佈結果。 – usr

+0

你可以給我們完整的堆棧跟蹤嗎? – ramiramilu

回答

2

您應該確保正確的文件名或容器名稱。 我使用這兩種方法。我相信它在兩個方面都有效。

你可以嘗試下面的代碼行嗎?

var result= blockBlob.DeleteIfExists();