2008-09-16 2 views

답변

1

zip 및 압축 해제 용으로 7Zip을 사용하려는 경우 TZip 구성 요소를 살펴보십시오. Zipper.pas 파일에서 찾을 수있는 자신의 목적을 위해 작은 래퍼를 작성했습니다. 재사용 해주십시오.

+0

. 그렇지 않으면 당신은 약간 꼬집어 있습니다. 300 메가 비트의 zip을 만든 다음, 그 300 메가 바이트의 zip 중 90 개를 TZip이있는 다른 zip으로 압축하면 재미있는 시간을 갖게됩니다. –

23

제다이 코드 라이브러리의 많은으로, 올리버 GIESEN의 대답에 확장, 나는 어떤 점잖은 문서를 찾을 수 없습니다, 그러나 이것은 나를 위해 작동 :

uses 
    JclCompression; 

procedure TfrmSevenZipTest.Button1Click(Sender: TObject); 
const 
    FILENAME = 'F:\temp\test.zip'; 
var 
    archiveclass: TJclDecompressArchiveClass; 
    archive: TJclDecompressArchive; 
    item: TJclCompressionItem; 
    s: String; 
    i: Integer; 
begin 
    archiveclass := GetArchiveFormats.FindDecompressFormat(FILENAME); 

    if not Assigned(archiveclass) then 
     raise Exception.Create('Could not determine the Format of ' + FILENAME); 

    archive := archiveclass.Create(FILENAME); 
    try 
     if not (archive is TJclSevenZipDecompressArchive) then 
     raise Exception.Create('This format is not handled by 7z.dll'); 

     archive.ListFiles; 

     s := Format('test.zip Item Count: %d'#13#10#13#10, [archive.ItemCount]); 

     for i := 0 to archive.ItemCount - 1 do 
     begin 
     item := archive.Items[i]; 
     case item.Kind of 
      ikFile: 
       s := s + IntToStr(i+1) + ': ' + item.PackedName + #13#10; 
      ikDirectory: 
       s := s + IntToStr(i+1) + ': ' + item.PackedName + '\'#13#10;//' 
     end; 
     end; 

     if archive.ItemCount > 0 then 
     begin 
//   archive.Items[0].Selected := true; 
//   archive.ExtractSelected('F:\temp\test'); 

     archive.ExtractAll('F:\temp\test'); 
     end; 

     ShowMessage(s); 
    finally 
     archive.Free; 
    end; 
end; 
4

델파이는 지금이 XE2에서 TZipFile 네이티브 크로스 플랫폼 우편 지원 :

How to extract zip files with TZipFile in Delphi XE2 and FireMonkey

+0

링크가 작동하지 않습니다. 그러나 이것은 아마도 도움이 될 수 있습니다. http://docwiki.embarcadero.com/Libraries/XE2/en/System.Zip.TZipFile – EMBarbosa

+1

이것은 LZMA 압축 아카이브를 지원하지 않습니다. – kbickar

0

나는 많은 솔루션을 시도하고 문제가 있었다,이 하나했다.

다운로드 https://github.com/zedalaye/d7zip 7z.dll 및 sevenzip.pas를 프로젝트 diroctory에 복사하고 프로젝트에 sevenzip.pas를 추가하십시오.

그런 다음 압축을 해제하려면이 옵션을 사용할 수 있습니다

using sevenzip; 

procedure Unzip7zFile (zipFullFname:string); 
    var 
    outDir:string; 
    begin 
    with CreateInArchive(CLSID_CFormat7z) do 
    begin 
     OpenFile(zipFullFname); 
     outDir := ChangeFileExt(zipFullFname, ''); 
     ForceDirectories (outDir); 
     ExtractTo(outDir); 
    end; 
    end; 

사용법 : 모든 압축 된 객체가 메모리에 맞지 않을 경우 잘 작동 TZip

Unzip7zFile(ExtractFilePath(Application.ExeName) + 'STR_SI_FULL_1000420.7z'); 
관련 문제