如何在C#中访问zip文件的内容 [英] How to access a zip files contents in C#

查看:924
本文介绍了如何在C#中访问zip文件的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问一个zip文件的内容.例如:说我想读取一个zip文件中的文本文件.

I want to access the contents of a zip file. eg: Say I want to read a text file inside a zip file. How would I declare the file path?

推荐答案

.NET Framework引入了GZipStreamDeflateStream 类用于流的压缩和解压缩.
Pong D. Panda 已经给出了有关GZipStream
的完美链接 看看那里有[DeflateStream] [ ^ ],以获取有关DeflateStream
.NET Framework has introduced GZipStream and DeflateStream classes for compression and decompression of streams.
Pong D. Panda have already given perfect link about GZipStream and
take a look there-[DeflateStream][^] for more details about DeflateStream


的更多详细信息,其他解决方案中提到的流允许您读取和写入压缩文件. ZIP文件(以及其他存档格式,如.gz,.tar等)不仅是压缩文件,而且结构数量巨大,您不能只使用其中一种流来读入其中.

我建议您使用 SharpZipLib [
The streams mentioned in the other solutions allow you to read and write a compressed file. A ZIP file (and other archive formats like .gz, .tar etc) are more than just a compressed file, there is a significant amount of structure and you can''t just read one in with one of these streams.

I suggest that you use SharpZipLib[^]. It''s open source but you''re allowed to use it in a proprietary solution.


使用google,您可以找到
Using google, you can find this.[^]


这篇关于如何在C#中访问zip文件的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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