miércoles, 3 de agosto de 2011

CloudDrive.Delete Method (borrar una unidad creada en azure)

 

Windows Azure Platform

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

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.CloudDrive (in microsoft.windowsazure.clouddrive.dll)

 



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);
}
}



 



link http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.clouddrive.delete.aspx

0 comentarios:

Publicar un comentario