导出 (0) 打印
全部展开
此主题尚未评级 - 评价此主题

CloudBlob.DeleteIfExists 方法 (BlobRequestOptions)

Deletes the blob if it exists.

命名空间: Microsoft.WindowsAzure.StorageClient
程序集: Microsoft.WindowsAzure.StorageClient(在 microsoft.windowsazure.storageclient.dll 中)
用法
Dim instance As CloudBlob
Dim options As BlobRequestOptions
Dim returnValue As Boolean

returnValue = instance.DeleteIfExists(options)
声明
Public Function DeleteIfExists ( _
	options As BlobRequestOptions _
) As Boolean
public boolean DeleteIfExists (
	BlobRequestOptions options
)
public function DeleteIfExists (
	options : BlobRequestOptions
) : boolean

参数

options

An object that specifies any additional options for the request.

返回值

true if the blob was deleted; otherwise, false.

The following code example deletes a blob if it already exists and creates a new blob by uploading a text string.

static void UploadTextToBlob(Uri blobEndpoint, string accountName, string accountKey)
{
    //Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    //Return a reference to the blob.
    CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");
            
    //Delete the blob if it already exists, also deleting any snapshots.
    BlobRequestOptions options = new BlobRequestOptions();
    options.DeleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;
    blob.DeleteIfExists();

    //Upload text to the blob, which will also create it.
    blob.UploadText("a text blob");
}


A blob that has snapshots cannot be deleted unless the snapshots are also deleted. If a blob has snapshots, use the DeleteSnapshotsOption property to specify how the snapshots should be handled when the blob is deleted.


此类型的任何公共静态(在 Visual Basic 中为 Shared)成员都是线程安全的。但不保证所有实例成员都是线程安全的。

开发平台

Windows XP Home Edition, Windows XP Professional, Windows Server 2003、Windows Server 2008 和 Windows 2000

目标平台

本文是否对您有所帮助?
(1500 个剩余字符)
感谢您的反馈

社区附加资源

显示:
© 2014 Microsoft. 版权所有。