【发布时间】:2016-08-09 00:42:03
【问题描述】:
我想将图像从 Azure blob 存储到 android 设备。我正在使用 Xamarin、C# 来开发 android 应用程序。 我可以在测试时将文件保存在本地系统中,但是当我将代码部署到移动设备时,文件没有保存在设备中。
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
// Retrieve storage account from connection string.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.GetContainerReference("blob");
foreach (IListBlobItem item in container.ListBlobs(null, false))
{
if (item.GetType() == typeof(CloudBlockBlob))
{
CloudBlockBlob pageBlob = (CloudBlockBlob)item;
string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
pageBlob.DownloadToFile(documentsPath+"inage.jpg",FileMode.Create);
//pageBlob.DownloadToByteArray(documentsPath + @"\inage.jpg", FileMode.);
}
}
【问题讨论】:
-
你有什么异常吗?您是否注意到“inage,jpg”中的拼写错误?尝试将一些文本文件保存到个人文件夹,可能是您无权写入。
标签: android c#-4.0 xamarin.android azure-mobile-services azure-blob-storage