http://www.7-zip.org/sdk.html
I can uses it compress a file, but can not find function of compress a Folder

- 37,241
- 25
- 195
- 267

- 229
- 2
- 8
-
Which version of Delphi? Would you consider ZIP which was added in XE? – David Heffernan Apr 21 '12 at 16:08
-
7z compression ratio bigger than ZIP and rar – babaloveyou Apr 22 '12 at 08:41
1 Answers
You'll have to create a .7z
archive, then include all files of the folder within. There is no direct "folder" compression: just compression of files. If you store a (relative) folder name within the file name (e.g. 'FolderName\FileName'), the folder 'FolderName' will appear within the archive.
You have within the SDK a ANSI-C compatible source code for 7z decompression with example.
You'll have to adapt it to add all files of the folder to the archive (using FindFirst / FindNext / FindClose
and recursion if you want the sub-folder to be included).
Edit: In fact, there is no .7z writing in the sdk. Only opening/extraction from a .7z archive within the sdk. You'll have to code it by hand... So perhaps the Using 7-Zip from Delphi? answer will help you here.

- 1
- 1

- 42,305
- 3
- 71
- 159
-
-
-
@DavidHeffernan In the SDK, you have two levels: 1. lzma compression (over stream or buffer); 2. .7z archive format. The .7z archive format does handle archive/directory features. – Arnaud Bouchez Apr 23 '12 at 13:48