Skip to content

ExportFile() ​

ts
function ExportFile(vfsFilePath, localFilePath: string): respBase;

This method of a VFS object exports a file from the VFS to the local file-system (directly-attached storage) of the operating system where Syncplify Server! is installed.

IMPORTANT

If the VFS is encrypted at-rest, this function also automatically takes care of decrypting the file during the import phase.

Parameters (function arguments) ​

ParameterTypeExplanation
vfsFilePathstringThe fully qualified path of the file relative to the root of the VFS in use
localFilePathstringThe fully qualified path, relative to the OS' file-system root, you wish the file to be exported to

Example ​

Let's say, for example, you have the following file in your current VFS (whatever that might be at runtime during a connected client session): /forecast/budget2025.xlsx

And let's assume you want to export it into the file-system (directly-attached storage) of your operating system, in the following target position: C:\Data\Budget.xlsx

This would be a barebone start for a script to do so:

ts
var vfs = GetCurrentVFS();
if (vfs != null) {
    // notice the \\ to escape the back-slash (if any are present)
    var resp = vfs.ExportFile("/forecast/budget2025.xlsx", "C:\\Data\\Budget.xlsx"); 
    if (resp.Ok()) {
        Log("File successfully exported");
    } else {
        Log("Error exporting file: " + resp.ErrorMsg());
    }
} else {
    Log("VFS was null");
}

IMPORTANT

The localFilePath parameter is system-dependent: on Windows it will be a Windows-style path, and on Linux it will be a POSIX path. The vfsFilePath is always POSIX regardless of the operating system you run Syncplify Server! on.