ZipFile.CreateFile
------------------

Creates a new file in the zip archive.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Compression](component_Compression.md) | [3.4](newinversion34.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

### Deprecated

This function was [deprecated](deprecated.md). Use [Archive.Compress](ArchiveCompress.md) instead.

MBS( "ZipFile.CreateFile"; FileName; Date { ; Comment; Encoding; zip64 } ) 

**MBS**( **"ZipFile.CreateFile";** /\* Creates a new file in the zip archive. \*/  
**$FileName**; /\* The filename to use. Can include path information with slashes as delimiter.e.g. "myfolder/test.txt" \*/   
**$Date**; /\* The file date to use.e.g. Get(CurrentTimestamp) \*/   
**$Comment**; /\* Optional; The file comment.e.g. "My first file." \*/   
**$Encoding**; /\* Optional; The text encoding for the comment parameter.   
Default is UTF-8.e.g. UTF8 \*/   
**$zip64**) /\* Optional; Pass 1 to enable 64-bit zip file.  
Default is 0 for 32-bit zip file.e.g. 0 \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| FileName | The filename to use. Can include path information with slashes as delimiter. | "myfolder/test.txt" |  |
| Date | The file date to use. | Get(CurrentTimestamp) |  |
| Comment | The file comment. | "My first file." | Optional |
| Encoding | The text encoding for the comment parameter.    Default is UTF-8.   Possible encoding names: ANSI, ISO-8859-1, Latin1, Mac, Native, UTF-8, DOS, Hex, Base64 or Windows. More listed in the [FAQ](https://www.monkeybreadsoftware.com/filemaker/faq.shtml). | UTF8 | Optional |
| zip64 | Pass 1 to enable 64-bit zip file.   Default is 0 for 32-bit zip file. | 0 | Optional |

### Result

Return OK or error.

### Description

Creates a new file in the zip archive.  
Use this method before writing data to the file using [ZipFile.WriteContainer](ZipFileWriteContainer.md) or [ZipFile.WriteText](ZipFileWriteText.md).  
Before creating files in archive, you need to open it using [ZipFile.Open](ZipFileOpen.md).  
If you want to encrypt file, please use [ZipFile.UsePassword](ZipFileUsePassword.md) before calling this function.  
  
Deprecated due to missing unicode support. Please use [Archive.Compress](ArchiveCompress.md) for new projects.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
For Server be aware that server has limited permissions and may not be able to access all files on a computer.  
### Examples

Creates a file:

 MBS ( "ZipFile.CreateFile"; "test.txt"; $date )  
### See also

- [Archive.Compress](ArchiveCompress.md)
- [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md)
- [ZipFile.Open](ZipFileOpen.md)
- [ZipFile.UsePassword](ZipFileUsePassword.md)
- [ZipFile.WriteContainer](ZipFileWriteContainer.md)
- [ZipFile.WriteFile](ZipFileWriteFile.md)
- [ZipFile.WriteHex](ZipFileWriteHex.md)
- [ZipFile.WriteText](ZipFileWriteText.md)

### Release notes

- **Version 7.5**
    - Changed [ZipFile.CreateFile](http://www.mbsplugins.eu/ZipFileCreateFile.shtml) to replace backslash in file path with slash to avoid errors.
- **Version 7.2**
    - Added zip64 parameter to [ZipFile.CreateFile](http://www.mbsplugins.eu/ZipFileCreateFile.shtml) function.

### Example Databases

- [Archives/ZipFile](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Archives/ZipFile.shtml#1ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 7.5pr6](https://www.mbsplugins.de/archive/2017-11-06/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 7.2pr1](https://www.mbsplugins.de/archive/2017-04-03/MBS_FileMaker_Plugin_version_7/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.5pr2](https://www.mbsplugins.de/archive/2014-12-01/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.4pr4](https://www.mbsplugins.de/archive/2014-10-06/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)
- [MBS Filemaker Plugin, version 4.3pr2](https://www.mbsplugins.de/archive/2014-07-15/MBS_Filemaker_Plugin_version_4/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 5/2013, Seite 21 bis 22](https://filemaker-magazin.de/neuigkeit/3701-Appetithappen-FMM_201305)

This function checks for a license.

Created 18th August 2014 , last changed 7th February 2023

  
[ZipFile.CompressFiles](ZipFileCompressFiles.md) - [ZipFile.Open](ZipFileOpen.md)

[HTML Version](ZipFileCreateFile.shtml)