This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v19.8
folder.copyTo( )

folder.copyTo( ) 


 

folder.copyTo ( destinationFolder {; newName}{; overwrite} ) -> Result 
Parameter Type   Description
destinationFolder  Object in Destination folder
newName  Text in Name for the copy
overwrite  Longint in fk overwrite to replace existing elements
Result  Object in Copied folder

The folder.copyTo( ) method copies the Folder object (source folder) into the specified destinationFolder

The destinationFolder must exist on disk, otherwise an error is generated.  

By default, the folder is copied with the name of the original folder. If you want to rename the copy, pass the new name in the newName parameter. The new name must comply with naming rules (e.g., it must not contain characters such as ":", "/", etc.), otherwise an error is returned.

If a folder with the same name already exists in the destinationFolder and is not empty, by default 4D checks its contents before copying the items and generates an error if a file with the same name exists. You can pass the fk overwrite constant in the overwrite parameter to ignore and overwrite the existing folder:

Constant Value Comment
fk overwrite 4

Overwrite existing elements, if any

 

Returned object

The method returns the copied Folder object.

Example  

You want to copy a Pictures folder from the user's Document folder to the Database folder:

 C_OBJECT($userImages;$copiedImages)
 $userImages:=Folder(fk documents folder+"/Pictures/")
 $copiedImages:=$userImages.copyTo(Folder(fk database folder);fk overwrite)



See also 

COPY DOCUMENT
folder.moveTo( )

 
PROPERTIES 

Product: 4D
Theme: File and Folder

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v19)
4D Language Reference ( 4D v19.1)
4D Language Reference ( 4D v19.4)
4D Language Reference ( 4D v19.5)
4D Language Reference ( 4D v19.6)
4D Language Reference ( 4D v19.7)
4D Language Reference ( 4D v19.8)