ssCore.FileSys.copyFileAsync

Copies an existing file to a new location and sends progress notifications at the specified intervals.


Availability:

First available in version 3.5 build 314.


Input Parameters:

from - A fully qualified path to the an existing file. This parameter supports monikers.

to - A fully qualified path to the new file. This parameter supports monikers.

failIfExists - [Optional] - Force the file copy to fail if the topath file exists before the copy. Valid values include: true,false. Default value is false.

chunkSize - [Optional] - Number of bytes to copy before trigerring a notification. Default value is 8192.


Output Parameters:

No output parameters.


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.FileSys.copyFileAsync( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

This method can only be called asynchronously.


Notes:

Both from and to must be fully qualified file names, you can't specify a file for from and a folder for to as you do with the DOS copy command.

You don't have to use the same file name at the end of the path for the from and to files. Using different names means you can rename files as part of the copy operation.

Use the FileSys.setNotify and FileSys.clearNotify functions to receive the copy progress notifications.

                

Examples:

ssDebug.trace("Copy operation starting.");
ssCore.FileSys.setNotify({event:"onCopyProgress"}, {callback:"CopyProgress", scope:this});
ssCore.FileSys.copyFileAsync({from:"startdir://source.txt", to:"desktop://destination.txt"}, {callback:"CopyComplete", scope:this});

function CopyProgress(ret_obj, cb_obj, err_obj)
{
if (ret_obj.success)
{
ssDebug.trace(" bytes copied: " + ret_obj.result);
}
}

function CopyComplete(ret_obj, cb_obj, err_obj)
{
    ssCore.FileSys.clearNotify({event:"onCopyProgress"});
if (ret_obj.success)
{
        ssDebug.trace("Copy operation ended successfully.");
    }
    else
    {
        ssDebug.trace("Copy operation ended with an error. " + err_obj.description);
    }
}