压缩时,加密码成功,用winrar可以解开,但是自己用程序解时只能解开一个文件,再到while循环时就出现文件头错误了,请高手指点,急 ZipInputStream s = new ZipInputStream(File.OpenRead(zipFileName));
if(strPassWord != "")
{
s.Password = strPassWord;
}
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
if(strPassWord != "")
{
s.Password = strPassWord;
}
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
s.SetLevel(6); // 0 - store only to 9 - means best compression
s.Password = "pwd";//这个我添加的
这样压缩的包用下面的方法可以正确解压。
在解密的时候我使用的是UnZipFile,修改如下:
ZipInputStream s = new ZipInputStream(File.OpenRead(args[0]));
s.Password = "pwd";//这是我添加的
ZipEntry theEntry;
其他代码就不帖了,下载一个084SharpZipLib_SourceSamples就可以看到。
我这样修改之后可以实现带加密的压缩,没有什么错啊。请仔细检查你的代码和逻辑,解压时的包是否是加密后的压缩包?gz...
upcstudent at 163.com