내보내기(0) 인쇄
모두 확장

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.


이 형식의 모든 public static(Shared, Visual Basic의 경우) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

개발 플랫폼

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2008 및 Windows 2000

대상 플랫폼

커뮤니티 추가 항목

표시:
© 2014 Microsoft