0
我正在开发应用程序,其中我先检查图像是否存在于独立存储中。如果图像不存在,那么我先下载然后将它们存储在独立存储中。但是我得到异常“类型“System.ObjectDisposedException”的异常出现在mscorlib.ni.dll但在用户代码“在using (IsolatedStorageFileStream mystream = istore.CreateFile(item.ImageUrl)).
在后台独立存储中存储图像
private void checkimage(Model item)
{
using (IsolatedStorageFile istore = IsolatedStorageFile.GetUserStoreForApplication())
{
if (istore.FileExists(item.ImageUrl))
{
}
else
{
BitmapImage imgage = new BitmapImage(new Uri(item.ImageUrl, UriKind.Absolute));
imgage.CreateOptions = BitmapCreateOptions.BackgroundCreation;
imgage.ImageOpened += (o, e) =>
{
using (IsolatedStorageFileStream mystream = istore.CreateFile(item.ImageUrl))
{
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(mystream);
WriteableBitmap wb = new WriteableBitmap(bitmap);
Extensions.SaveJpeg(wb, mystream, wb.PixelWidth, wb.PixelHeight, 0, 85);
mystream.Close();
}
};
}
}
}
谢谢。这是你建议的同样的问题 –
这是因为我可以存储在独立存储中的文件的名称非常大。 –