銷售: 1-800-867-1380

CloudDrive.Delete 方法

Deletes the page blob associated with this Windows Azure drive and all data that it contains.

命名空間: Microsoft.WindowsAzure.StorageClient
組件: Microsoft.WindowsAzure.CloudDrive (在 microsoft.windowsazure.clouddrive.dll 中)

'用途
Dim instance As CloudDrive

instance.Delete

public void Delete ()
public void Delete ()
public function Delete ()

The following example creates and mounts a Windows Azure drive, writes some files to it, then unmounts and deletes the drive.


public void UnmountAndDeleteDrive()
{
    // Use the storage emulator.
    CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;

    // Create the Blob service client.
    CloudBlobClient client = storageAccount.CreateCloudBlobClient();

    // Create the container for the drive if it does not already exist.
    CloudBlobContainer container = new CloudBlobContainer("mydrives", client);
    container.CreateIfNotExist();

    // Get a reference to the page blob that will back the drive.
    CloudPageBlob pageBlob = container.GetPageBlobReference("myvhd");

    // Return a reference to the drive backed by the specified page blob. 
    CloudDrive drive = new CloudDrive(pageBlob.Uri, storageAccount.Credentials);

    try
    {
        // Create a 20 MB drive.
        drive.Create(20);

        // Mount the drive.
        string driveLetter = drive.Mount(0, DriveMountOptions.None);

        // Write some files to the drive.
        for (int i = 0; i < 1000; i++)
        {
            System.IO.File.WriteAllText(driveLetter + "\\" + i.ToString() + ".txt", "Test");
        }

        // Write out a file's length.
        FileInfo file = new FileInfo(driveLetter + "\\0.txt");
        System.Diagnostics.Debug.WriteLine(file.Length);

        // Unmount the drive.
        drive.Unmount();

        // Delete the drive.
        drive.Delete();
    }
    catch (CloudDriveException e)
    {
        System.Diagnostics.Debug.WriteLine(e.Message);
    }
}


Before you can delete a drive, you must call Unmount to unmount the drive. Attempting to delete the drive without unmounting it results in a CloudDriveException.

If the page blob backing the drive has associated snapshots, you must delete the snapshots before deleting the drive. To delete snapshots, call the Delete, making sure to set the DeleteSnapshotsOption on the request.

Caution警告
Use the Delete method with caution, as calling it will delete the data in your drive irretrievably.


任何這個類型的公用靜態 (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。 並非所有的執行個體成員都是安全執行緒。

開發平台

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

目標平台

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

顯示:
© 2014 Microsoft