SharpZipLib解壓縮時中文名亂碼 解決

2022-04-03 12:31:32 字數 613 閱讀 6409

icsharpcode.sharpzlib這個元件直接使用會出現解壓縮中文時出現錯誤。所以需要更改一下作者的源**。。。以下為版本0.86為例。

1)在源**中找到 zipinputsteam.cs檔案,開啟它然後定位到 getnextentry()這個函式內。

2)在getnextentry裡面有一句**是得到檔名的**。

string name = zipconstants.converttostringext(flags, buffer);

我們現在要改造一下這一句**,其實就是變一下codepage屬性。。。。**參考如下:

int externallydefinedcodepage = zipconstants.defaultcodepage; 

zipconstants.defaultcodepage =system.text.encoding.default.codepage;  //出現亂碼就是因為codepage不對造成的。

string name = zipconstants.converttostringext(flags, buffer);

zipconstants.defaultcodepage = externallydefinedcodepage;

c 使用SharpZipLib壓縮和解壓縮檔案

正常zip方式壓縮檔案,然後用wrar工具可以解壓出來 開始用wrar3.4版本的怎麼也解不出來,以為是不支援wrar解壓,後來改用3.9及4.11版本可以實現正常解壓,搞了半天時間,原來是版本問題,版本不對害死人啊 另外wrar壓縮時選擇 zip 選項壓縮時,再用此類進行解壓,也可以正常解壓。在此...

SharpZipLib壓縮解壓

using system using system.collections.generic using system.linq using system.text using system.io using icsharpcode.sharpziplib.zip namespace test zip...

利用SharpZipLib壓縮 解壓檔案

public class zipinfo 壓縮檔案 private void filetozip string path,string address 解壓到乙個目錄 public bool ziptofile string path,string addres s.close catch exce...