当前位置: 代码迷 >> Windows Mobile >> !读取IsolatedStorageFile中的图片显示报错
  详细解决方案

!读取IsolatedStorageFile中的图片显示报错

热度:72   发布时间:2016-04-25 07:18:25.0
求助!读取IsolatedStorageFile中的图片显示报错
我先用下面的代码将一张图片保存到独立存储中,
   using (IsolatedStorageFileStream isoStream = isofile.OpenFile(path ,
                                            FileMode.Create, FileAccess.Write))
                    {                      
                        byte[] bytes = new byte[imageSource.Length];
                        imageSource.Read(bytes, 0, (int)imageSource.Length);                       
                        isoStream.Write(bytes, 0, bytes.Length);
                        // imageSource.CopyTo(isoStream);   这样isoStream的Length仍然是0
                        isoStream.Flush();
                       
                    }


然后再读取:
 using (IsolatedStorageFileStream isoStream = isofile.OpenFile(path, FileMode.Open, FileAccess.Read))
                {
                   
                    BitmapImage bmp = new BitmapImage();
                    bmp.SetSource(isoStream);           // isoStream长度不为0,说明有图片吧?
                    return bmp;
                }


但是在执行到bmp.SetSource时会抛出异常:The component cannot be found.
请问这是什么原因呢?另外如果要读取图片并显示的话还能怎么做呢?谢了!

------解决方案--------------------
isoStream.Seek(0);
bmp.SetSource(isoStream);   

试试        
------解决方案--------------------
引用:
isoStream.Seek(0);
bmp.SetSource(isoStream);   

试试        

------解决方案--------------------
引用:
Quote: 引用:

isoStream.Seek(0);
bmp.SetSource(isoStream);   

试试        

笑毛?
------解决方案--------------------
谷歌一下 你就知道
  相关解决方案