delphi – 如何使用JCL压缩单元解决“Sevenzip:错误结果(000000
我正在使用JCL版本2.4.1.4571与Delphi XE3,并没有运气解压缩档案.我已经从JEDI的网站下载了dll,并尝试使用7-zip.org中的7z.dll(32位),但无论哪种方式,当我尝试“ExtractAll”时,我都会遇到同样的错误
见下面的功能: function TForm1.Decompress(FileName,DestDir: String): Boolean; var archiveclass: TJclDecompressArchiveClass; Myarchive: TJclDecompressArchive; begin Decompress := False; // Filename = name.7z or name.zip (simple test zips nothing fancy) // DestDir = fully qualified path to an existing directory archiveclass := GetArchiveFormats.FindDecompressFormat(FileName); Try if Assigned(archiveclass) then Begin Myarchive := archiveclass.Create(FileName); if (Myarchive is TJclSevenZipDecompressArchive) then Begin try Myarchive.ListFiles; { Fails without doing this first } { ExtractAll (AutocreateSubDir) must be set true if arc has directories or it will crash } Myarchive.ExtractAll(DestDir,True); Decompress := True; except on E: EJclCompressionError do Begin ShowMessage(e.Message); End; end; End Else ShowMessage('Not supported by 7z.dll'); End; Finally MyArchive.Free; End; end; 当我执行MyArchive.ExtractAll行时,我得到一个异常Sevenzip:错误结果(00000001)函数不正确.我将代码基于StackOverflow上的其他代码.我错过了我需要先做的事情还是这个错误?我用MyArchive.ListFiles替换了提取行并得到了同样的错误(我在这里看到了一个例子;但是,我还没有看出ListFiles的目的. 编辑:使用7-zip创建了一系列不同类型的存档,并尝试使用我的程序解压缩每个存档.我发现的第一件事是,如果存档包含文件目录,如果没有将第二个参数设置为True,ExtractAll将崩溃.然后我用不同的压缩方法测试了档案. 使用LZMA2 Ultra压缩的.7z存档会产生Hresult = 1错误 使用LZMA Ultra压缩的.zip存档会产生Hresult = 1错误 .zip档案使用Deflate或deflate64的风格都可以正常工作. 看起来该库根本不处理LZMA压缩.由于7z.dll无法处理它是没有意义的,我猜测问题在于JEDI JCL代码.我需要能够使用LZMA压缩/解压缩.7z和.zip这个库,或者我可以刚开始使用内置的zip东西.任何进一步的建议将不胜感激. 解决方法
进一步谷歌搜索这个问题出现了
http://sourceforge.net/p/jcl/mailman/message/21371812/
看起来“如果文件名不是小写的话,FindDecompressFormat找不到存档格式.” 我尝试更改我传递给小写的字符串,并成功解压缩了LZMA存档. archiveclass := GetArchiveFormats.FindDecompressFormat(lowercase(FileName)); JEDI JCL如果有任何文件的话,它将是一个很酷的图书馆 – 很遗憾. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |