babaloveyou
babaloveyou

Reputation: 229

How to compress a Folder uses lzma sdk?

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

Upvotes: 4

Views: 4040

Answers (1)

Arnaud Bouchez
Arnaud Bouchez

Reputation: 43023

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.

Upvotes: 2

Related Questions