4

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
babaloveyou
  • 229
  • 2
  • 8

1 Answers1

2

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.

Community
  • 1
  • 1
Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159