Skip to content

$ps.file.copyFile

Overview

Copies the specified file using $ps.file in a Server Script.

Prerequisites

You need to set DisableServerScriptFile in Script.json to false.

Syntax

$ps.file.copyFile(section, sourcePath, destPath)

Parameters

Parameter Type Required Description
section string Yes The section name. For sections, refer to "About Sections" in $ps.file.
sourcePath string Yes The path of the source file. Use "/" as the directory separator on both Windows and Linux.
destPath string Yes The path of the destination file. Use "/" as the directory separator on both Windows and Linux.

Return Value

Returns true if the file could be copied, and false if it could not.

Exceptions

If an exception occurs inside C#, the exception class name and the error message are put into an Error object and the exception is raised within the server script.

Usage Examples

The following example copies the specified file in the directory "parts_01" on the web server to the directory "parts_02".

JavaScript
$ps.file.copyFile('01_develop', 'parts_01/document.txt', 'parts_02/document.txt');

The following example copies "document.txt" in the directory "parts_01" on the web server as "document_2.txt" in the same directory.

JavaScript
$ps.file.copyFile('01_develop', 'parts_01/document.txt', 'parts_01/document_2.txt');

Supported Versions

Supported Version Description
1.4.19.0 and later Function added