2014-01-07 116 views
0

我正在開發一個應用程序,在該應用程序中,我從Web服務器下載圖像,然後存儲在獨立存儲器中。不過,我在BI.SetSource(Str_ri.Stream);將圖像加載並存儲在獨立存儲器中

這裏得到一個錯誤是我的代碼:

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(); 
     } 
    } 

回答

相關問題