private void MountSnapshot(string snapshotUri) { string storageAccountName = txtStorageAccountName.Text; string storageAccountKey = txtStorageAccountKey.Text; try { LocalResource resource = WindowsAzureSystemHelper.GetLocalStorageResource(LOCAL_STORAGE_NAME); int cacheSize = int.Parse(txtCacheSize.Text); if (resource.MaximumSizeInMegabytes < cacheSize) { throw new Exception(String.Format("Cache size {0} MB cannot be more than maximum permitted size {1} MB", cacheSize, resource.MaximumSizeInMegabytes)); } bool wasAlreadyMounted; string driveName = WADriveHelper.MountAzureDrive(storageAccountName, storageAccountKey, new Uri(snapshotUri), LocalStoragePath + txtCacheDirName.Text + ".snapshot", int.Parse(txtCacheSize.Text), int.Parse(txtDriveSize.Text), DriveMountOptions.None, out wasAlreadyMounted); lblMsg.Text = String.Format("Mounted Snapshot {0} to Drive {1}", snapshotUri, driveName); ListAllMountedDrives(); } catch (Exception ex) { lblMsg.Text = ex.Message; } }
private void MountDrive() { string storageAccountName = txtStorageAccountName.Text; string storageAccountKey = txtStorageAccountKey.Text; try { LocalResource resource = WindowsAzureSystemHelper.GetLocalStorageResource(LOCAL_STORAGE_NAME); int cacheSize = int.Parse(txtCacheSize.Text); if (resource.MaximumSizeInMegabytes < cacheSize) { throw new Exception(String.Format("Cache size {0} MB cannot be more than maximum permitted size {1} MB", cacheSize, resource.MaximumSizeInMegabytes)); } bool wasAlreadyMounted; string driveName = WADriveHelper.MountAzureDrive(storageAccountName, storageAccountKey, txtContainerName.Text, txtPageBlobName.Text, LocalStoragePath + txtCacheDirName.Text, int.Parse(txtCacheSize.Text), int.Parse(txtDriveSize.Text), DriveMountOptions.None, out wasAlreadyMounted); lblMsg.Text = String.Format("Mounted Blob {0} to Drive {1}", txtPageBlobName.Text, driveName); if (cbCreateTestFile.Checked) { try { WADriveHelper.WriteTestFile(driveName + System.Guid.NewGuid().ToString("N") + "silverlining-test.txt", "test"); } catch (Exception ey) { lblMsg.Text = "Could not write test file to the drive " + ey.Message; } } ListAllMountedDrives(); FillTree(); } catch (Exception ex) { lblMsg.Text = ex.Message; } }