我如何解压缩数据流,而读它在C# [英] how do i unzip stream while reading it in c#

查看:87
本文介绍了我如何解压缩数据流,而读它在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看在我的应用程序中的zip文件,我不想要提取后,我读了一切。

i read a zip file in my application and i don't want to extract after i read it all ..

我要提取它,而我读它。

i want to extract it while i am reading it.

让我怎么提取的字节流文件,而我读它?

so how do i extract stream of bytes for a file while i am reading it ?

推荐答案

的的 GZipStream 和的 DeflateStream 类是围绕一个正常的Stream对象包装程序。这意味着,你可以提取你打算沿),整个文件下载之前及数据b)无需加载在所有的数据到内存中。

The GZipStream and DeflateStream classes are wrappers around a normal Stream object. This means that you can extract the data as you're going along before a) the whole file has been downloaded and b) without loading all of the data in to memory.

这些都是在.NET 4以上可用,否则你将需要使用# ZipLib 中的建议。

These are available in .NET 4 upwards, otherwise you'll need to use #ZipLib as suggested.

编辑: 经过四处寻找它会出现#ZipLib绝对是前锋用这种方式。相同的原理也适用于这些类在它们的流,它们可以作为正在下载的文件或读取通过网络和它们不需要整个文件是在存储器中。我目前使用它在一个项目从HTTP服务器上打开zip文件,所以我已经看到了它在行动!

After looking around it would appear that #ZipLib is definitely the way forwards with this. The same principles apply to these classes in that they are streams, they can work as the file is being downloaded or read over a network and they don't require the whole file to be in memory. I'm currently using it in a project to open zip files from an http server, so I've seen it in action!

这篇关于我如何解压缩数据流,而读它在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆