Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Creates a new archive.

Component Version macOS Windows Linux Server iOS SDK
Archive 13.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "Archive.Create"; Format; Filter { ; Destination; Options; Password } )   More


Parameter Description Example Flags
Format The format to use.
Formats: ar, arbsd, argnu, arsvr4, bsdtar, cd9660, cpio, gnutar, iso, iso9660, mtree, mtree-classic, newc, odc, oldtar, pax, paxr, posix, raw, rpax, shar, shardump, ustar, v7tar, v7, warc, xar, zip.
Filter The filter to use.
For zip format can be store or deflate.
Filters: b64encode, bzip2, compress, grzip, gzip, lrzip, lz4, lzip, lzma, lzop, uuencode, xz, zstd.

Not all filters can be combined with all formats.
Destination The native file path to the destination archive.
Or empty or file name for container.
"C:\" Optional
Options The options to pass to writer.
This is a comma-separated list of options. Option names can be prefixed with module name.

Sample options:
"compression-level=9¶hdrcharset=UTF-8" Optional
Password The passphrase to use for password protection.
Usually only used when an encryption option is set.
"secret" Optional


Returns OK or error.


Creates a new archive.
You may call Archive.AddContainer, Archive.AddFile and Archive.AddText to add files and later call Archive.Close function to finish.

Supports various compression algorithms and encryption.
The archive usually should not contain the absolute paths of the files, so we need a base path and relative to that base path the list of files and folders to zip.


Create a zip file on desktop:

Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; "/Users/cs/Desktop/") ]
# add a file from desktop folder:
Set Variable [ $r ; Value: MBS( "Archive.AddFile"; "test.png"; "/Users/cs/Desktop") ]
# add a text file:
Set Variable [ $r ; Value: MBS( "Archive.AddText"; "Hello World!"; "UTF-8"; "test.txt") ]
# add something from container field:
Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Kontakte::Foto) ]
# and close file.
Set Variable [ $r ; Value: MBS( "Archive.Close") ]

Create a zip and store in container:

Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; "") ]
# add file from desktop:
Set Variable [ $r ; Value: MBS( "Archive.AddFile"; "test.png"; "/Users/cs/Desktop") ]
# add a text file:
Set Variable [ $r ; Value: MBS( "Archive.AddText"; "Hello World!"; "UTF-8"; "test.txt") ]
# add a picture:
Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; MyTable::MyPhoto) ]
# close and get the container value:
Set Variable [ $container ; Value: MBS( "Archive.Close") ]
# Store in a Field:
Set Field [ MyTable::MyZip ; $container ]
Commit Records/Requests [ With dialog: Off ]

Compress PDF containers into a zip file:

Set Variable [ $path ; Value: MBS( "Path.AddPathComponent"; MBS( "Folders.UserDesktop" ); "" ) ]
Set Variable [ $r ; Value: MBS( "Archive.Create"; "zip"; "deflate"; $path) ]
If [ MBS("IsError") ]
    Show Custom Dialog [ "Failed to create zip archive." ; $r ]
    Exit Script [ Text Result: ]
End If
Go to Record/Request/Page [ First ]
Set Variable [ $destPage ; Value: 1 ]
    Set Variable [ $r ; Value: MBS( "Archive.AddContainer"; Merge PDFs::InputPDF) ]
    Go to Record/Request/Page [ Next ; Exit after last: On ]
End Loop
Set Variable [ $r ; Value: MBS( "Archive.Close") ]

Create 7zip archive:

MBS( "Archive.Create"; "7zip"; ""; $path)

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 13th February 2023, last changed 13th June 2024

Archive.Content - Archive.Extract