下面的例子是从zip压缩文件解压出jpg文件流,再显示出来。

 

StorageFile zip = await KnownFolders.PicturesLibrary.GetFileAsync("1.zip");            

using (ZipArchive archive = new ZipArchive((await zip.OpenAsync(FileAccessMode.ReadWrite)).AsStream(), ZipArchiveMode.Update))       
{
        InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();
        using (var stream = archive.GetEntry("1.jpg").Open())
       {
            await stream.CopyToAsync(ras.AsStreamForWrite()); //Stream转成IRandomAccessStream
            await ras.FlushAsync();
            ras.Seek(0); //这句是关键,必须把流的起点重新设置
            BitmapImage bi = new BitmapImage();
            bi.SetSource(ras);
            img.Source = bi; } }

 

相关文章:

  • 2021-06-20
  • 2022-02-10
  • 2022-12-23
  • 2022-01-27
  • 2022-12-23
  • 2021-06-21
  • 2021-07-24
  • 2021-12-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-22
  • 2021-08-31
  • 2021-06-02
  • 2021-12-14
相关资源
相似解决方案