The File object represents a file or directory on disk and can be used to navigate / access the file system from HISEScript.

In order to use it, call the Filesystem API class to get a folder from where you navigate to the file you want to modify / load.

Be aware that there is no possibility of writing / loading files using absolute paths (eg. C:\MyFolder ) because it is not portable across operating systems (and even computers).

Class methods


Returns the new directory created at the file location, if directory doesn't already exist

File.createDirectory(String directoryName)


Deletes the file or directory WITHOUT confirmation.



Extracts the ZIP archive if this file is a .zip file.

File.extractZipFile(var targetDirectory, bool overwriteFiles, var callback)

This method will extract a standard ZIP file (without password protection) to the given target directory (which can be either a file path String or a File object).

The extraction process will be executed on the sample loading thread and you can assign a callback that is executed to track the extraction progress.

The callback expects a single parameter that will contain a JSON object with the following properties:

Property Type Description
Cancel bool Set to false . If you want to abort the extraction process, just set this flag to true.
Target String The target directory as file path.
Error String A error message if something went wrong during extracting.
Progress double the progress from 0.0 to 1.0. Be aware that this tracks only the number of files extracted vs. the total number of files, so if you have one big file inside the archive, it will not work.
NumBytesWritten int the number of bytes that have been extracted.
CurrentFile String the relative path of the file that is currently being extracted.
Status int a status flag indicating the state of the extraction: 0 at the beginning, 1 while extracting and 2 at the end.

The callback will be executed at the beginning of the extraction (with the Status flag 0 ) and at the end (with the Status flag 2 ) as well as when an error occurs.

If you extract a small archive (less than ~400 files), the callback will also be executed for each file (this limit prevents the scripting queue to be clogged with huge archives).


Returns a child file if this is a directory.

File.getChildFile(String childFileName)


Returns the parent directory as File.



Checks if this file exists and is a directory.



Checks if this file exists and is a file.



Loads the given file as object.


This tries to parse the given file as JSON object and return it. If you are storing complex data, this will be the most convenient option.


Loads the given file as text.



Loads the encrypted object using the supplied RSA key pair.

File.loadEncryptedObject(String key)

This function will load a JSON object from a file that has been written with File.writeEncryptedObject()

The encryption uses Blowfish encryption, so it should be able to encrypt / decrypt pretty fast.

You can use these functions to create an authentification scheme that stores the license key in a file in order to bypass online activation.


Opens a Explorer / Finder window that points to the file.

This opens a OS specific file browser that will reveal the file to the user.


Returns a String representation of that file.

File.toString(int formatType)

You can use this to display the filename on your UI.

The formatType argument is expected to be one of the constants supplied in the File object:

The following table will show the formatting for the file C:\MyFolder\Textfile.txt

Name Example
FullPath C:\MyFolder\Textfile.txt
NoExtension Textfile
OnlyExtension .txt
Filename Textfile.txt


Writes the given data (either a Buffer or Array of Buffers) to a audio file.

File.writeAudioFile(var audioData, double sampleRate, int bitDepth)


Encrypts an JSON object using the supplied key.

File.writeEncryptedObject(var jsonData, String key)

This function will encrypt the JSON object with the given key and write it to the specified file. The key can be up to 72 characters long.

In order to read the encrypted file, use File.loadEncryptedObject() with the same key.


Replaces the file content with the JSON data.

File.writeObject(var jsonData)


Replaces the file content with the given text.

File.writeString(String text)

It will return true if the file operation was completed successfully or false if there was an error during the operation.