I am developing an app in which I download images from the Web server and then store in Isolated Storage. However, I'm getting an error at BI.SetSource(Str_ri.Stream);
Here is my code:
string name = "image" + current.ImageId;
using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication())
{
if (ISF.FileExists(name))
{
}
else
{
IsolatedStorageFileStream filestream = ISF.CreateFile(name);
StreamResourceInfo sr = null;
Uri ur = new Uri(name, UriKind.Relative);
sr = Application.GetResourceStream(ur);
BitmapImage bi = new BitmapImage();
bi.SetSource(sr.Stream);
WriteableBitmap wr_B = new WriteableBitmap(bi);
System.Windows.Media.Imaging.Extensions.SaveJpeg(wr_B, filestream, wr_B.PixelWidth, wr_B.PixelHeight, 0, 85);
wr_B.SaveJpeg(filestream, wr_B.PixelWidth, wr_B.PixelHeight, 0, 85);
filestream.Close();
}
}