我正在編寫一個簡單的UWP應用程序,其中用戶將InkCanvas筆觸信息發送到Azure blockBlob,然後檢索一些不同的InkCanvas筆觸容器信息以呈現到畫布。UWP CloudBlob.DownloadFileAsync訪問被拒絕錯誤
使用StrokeContainer.saveAsync()將.ink文件保存到applicationData本地文件夾到相同的位置和文件名(它將被每個事務替換),然後使用CloudBlockBlob.uploadAsync()將其上傳。
我嘗試從Azure服務器下載文件時出現問題 - 出現「拒絕訪問」錯誤。
async private void loadInkCanvas(string name)
{
//load ink canvas
//add strokes to the end of the name
storageInfo.blockBlob = storageInfo.container.GetBlockBlobReference(name + "_strokes");
//check to see if the strokes file exists
if (await storageInfo.blockBlob.ExistsAsync){
//then the stroke exists, we can load it in.
StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile storageFile = await storageFolder.CreateFileAsync("ink.ink", CreationCollisionOption.ReplaceExisting);
using (var outputStream = await storageFile.OpenAsync(FileAccessMode.ReadWrite))
{
await storageInfo.blockBlob.DownloadToFileAsync(storageFile);//gives me the "Access Denied" error here
}
}
}
任何幫助將不勝感激,所有我在網上找到的,你不應該把直接路徑到目標位置,而要用ApplicationData.Current.LocalFolder。
請看看這裏:http://www.damirscorner.com/blog/posts/20120419-ClosingStreamsInWinRt.html。 HTH。 –