嗨,我正在从以下代码下载图像
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, imageUri);
HttpResponseMessage response = await http.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
var imageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
var fs = await imageFile.OpenAsync(FileAccessMode.ReadWrite);
DataWriter writer = new DataWriter(fs.GetOutputStreamAt(0));
writer.WriteBytes(await response.Content.ReadAsByteArrayAsync());
await writer.StoreAsync();
writer.DetachStream();
await fs.FlushAsync();
fs.Dispose();
但是当我尝试在运行下载代码后立即打开它时..借助以下代码并尝试将其设置为图像控件的源
var imageFile = await ApplicationData.Current.LocalFolder.GetFileAsync(imageName);
IRandomAccessStream stream = await imageFile.OpenAsync(FileAccessMode.Read);
imageControl.SetSource(stream);
它抛出以下异常
访问被拒绝。(来自 HRESULT 的异常:0x80070005 (E_ACCESSDENIED))
内部例外是:
空值
请让我知道我在什么时候做错了。
提前致谢