每当我尝试从本地文件检索图像时,上述异常发生在 await bitmapImage.SetSourceAsync(fileStream);
行。
这是我用来存储和检索图像文件的方法。
public async Task<BitmapImage> RetrieveImageFromFile(String fileName)
{
try
{
StorageFile localFile = await _storageFolder.GetFileAsync(fileName + "Img");
BitmapImage bitmapImage = new BitmapImage();
using (IRandomAccessStream fileStream = await localFile.OpenAsync(FileAccessMode.Read))
{
await bitmapImage.SetSourceAsync(fileStream);
}
return bitmapImage;
}
catch(Exception e)
{
return null;
}
}
public async void WriteImageToFile(string fileName, IRandomAccessStreamWithContentType stream )
{
StorageFile file = await _storageFolder.CreateFileAsync(fileName + "Img", CreationCollisionOption.ReplaceExisting);
Stream streamToSave = stream.AsStreamForWrite();
using (Stream fileStram = await file.OpenStreamForWriteAsync())
{
streamToSave.CopyTo(fileStram);
}
}
WriteImageToFile 方法的输入流是从 contact.Thumbnail.OpenReadAsync() 方法中检索的
有什么帮助吗?
最佳答案
只是把我的评论变成一个答案,因为它一直在帮助人们:
0x88982f50 错误通常与未能正确读取/解码图像文件有关。验证您的文件格式是否正确。 Google 88982f50 可查看数十个可能相关的修复程序,所有修复程序都与图像文件 I/O 有关。我从来没有找到错误的确切来源,但这也是我的问题……文件错误。
关于c# - 找不到该组件。 (来自 HRESULT : 0x88982F50) 的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30273307/