我尝试从中获取图像流,IsolatedStorage
然后为其分配位图图像,如下所示:
using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(filePath, FileMode.Open, isolatedStorage))
{
BitmapImage image = new BitmapImage();
image.SetSource(fileStream);
return image;
}
但image.SetSource(fileStream)
实际上,我收到了这个错误:
找不到该组件。(来自 HRESULT 的异常:0x88982F50)
更新我使用块删除,但仍然恰好在到达该行时发生错误。也许我一开始就写错了文件?这是我为保存文件所做的:
IsolatedStorageFile isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
if (!isolatedStorage.DirectoryExists("MyImages"))
{
isolatedStorage.CreateDirectory("MyImages");
}
var filePath = Path.Combine("MyImages", name + ".jpg");
using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(filePath, FileMode.Create, isolatedStorage))
{
StreamWriter sw = new StreamWriter(fileStream);
sw.Write(image);
sw.Close();
}