如何用ZLib .NET 解压缩多个文件

8536105 2012-03-21 10:00:24
ZLib .NET 的demo中只有单个文件的解压缩,现在一个压缩包中有多个文件。不知道怎样解压缩。
还有这个文件是不能用Zip,Rar打开的。请教各位了!
...全文
279 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
白色的海 2012-03-21
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 8536105 的回复:]
这个文件是不能用Zip,Rar打开的
[/Quote]
可以啊,我试了。
有可能是字符编码的问题,被压缩的文件里有没有中文的,支持中文不太好。
8536105 2012-03-21
  • 打赏
  • 举报
回复
这个文件是不能用Zip,Rar打开的
白色的海 2012-03-21
  • 打赏
  • 举报
回复
使用dotnetzip,可以压缩解压缩,压缩完的也能用zip,rar打开。
http://dotnetzip.codeplex.com/
8536105 2012-03-21
  • 打赏
  • 举报
回复
试过的,打不开文件。压缩包不是Zip格式,ZLib .NET 能解压缩。
mrsupersky 2012-03-21
  • 打赏
  • 举报
回复
http://dotnetzip.codeplex.com/


using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
// add the report into a different directory in the archive
zip.AddFile("c:\\Reports\\2008-Regional-Sales-Report.pdf", "files");
zip.AddFile("ReadMe.txt");
zip.Save("MyZipFile.zip");
}

Dim ZipToUnpack As String = "C1P3SML.zip"
Dim TargetDir As String = "C1P3SML"
Console.WriteLine("Extracting file {0} to {1}", ZipToUnpack, TargetDir)
Using zip1 As ZipFile = ZipFile.Read(ZipToUnpack)
AddHandler zip1.ExtractProgress, AddressOf MyExtractProgress
Dim e As ZipEntry
' here, we extract every entry, but we could extract
' based on entry name, size, date, etc.
For Each e In zip1
e.Extract(TargetDir, ExtractExistingFileAction.OverwriteSilently)
Next
End Using

以上是官方的案例,亦可以压缩文件夹,又可以解压缩文件夹

而且 dotnetzip (lib) 是Zip压缩算法的标准实现。

可以解压所有的基于标准zip算法的zip文件,支持多文件多目录文件夹的压缩和解压。

遍历即OK。



mrsupersky 2012-03-21
  • 打赏
  • 举报
回复
DotNetZipLib 比较容易使用
到CodePlex.net 上搜索一下。第一个就是
该项目一个提供 3个DLL,其中有一个就是现成的封装好的文件操作的DLL。

该项目的性能也很不错。
8536105 2012-03-21
  • 打赏
  • 举报
回复
我试了,我的包只能用ZLib .NET 打开,demo中只有单个文件解压的,我的包中有多个文件
白色的海 2012-03-21
  • 打赏
  • 举报
回复
原来你只想要压缩算法。
8536105 2012-03-21
  • 打赏
  • 举报
回复
你没明白我的意思,我要的是解压,压缩包是不能用Zip,Rar打开的

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧