以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  ExtractAll中文乱码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=148252)

--  作者:lur320
--  发布时间:2020/4/3 11:00:00
--  ExtractAll中文乱码
在使用ZipFile的代码时,解压缩中文的文档就是乱码。之前压缩会有乱码,我用了下面的代码压缩,请问解压缩用什么?

Dim zipedFile As String = filenam
        Using fs As io.FileStream = io.File.OpenRead(fileToZip)
        Dim buffer As Byte() = New Byte(fs.Length - 1) {}
        fs.Read(buffer, 0, buffer.Length)
        fs.Close()
        Using ZipFile As io.FileStream = io.File.Create(zipedFile)
        Using ZipStream As ICSharpCode.SharpZipLib.zip.ZipOutputStream = New ICSharpCode.SharpZipLib.zip.ZipOutputStream(ZipFile)
        Dim fileName As String = fileToZip.SubString(fileToZip.LastIndexOf("\\") + 1)
        Dim ZipEntry = New ICSharpCode.SharpZipLib.zip.ZipEntry(fileName)
        ZipStream.PutNextEntry(ZipEntry)
        ZipStream.SetLevel(7)
        ZipStream.Write(buffer, 0, buffer.Length)
        ZipStream.Finish()
        ZipStream.Close()
    End Using
End Using
End Using


--  作者:有点蓝
--  发布时间:2020/4/3 11:07:00
--  
这个建议看官方的帮助文档。或者百度:https://www.cnblogs.com/hbh123/p/9566334.htmlhttps://blog.csdn.net/AAA123524457/article/details/89309454
--  作者:lur320
--  发布时间:2020/4/3 11:15:00
--  
你理解错我的意思了。我用的是狐表的ZipFile解压缩含有中文文件名的ZIP时,会出现乱码。

压缩的那个只是我的例子。

--  作者:有点蓝
--  发布时间:2020/4/3 11:29:00
--  
试试这个:
UseUtf8Encoding逻辑型,压缩包中的文件名和注释是否采用UTF8格式编码。

Dim zip As New zipFile
zip.UseUtf8Encoding = true ‘false
压缩的时候指定Utf8编码。

如果还不行,建议还是使用同一个组件处理解压缩吧