CopyDirectory Use Examples
Basic CopyDirectory Use
In this example, we check if the source directory exists, if so we copy it to a target directory and copy all the sub directories. Since the target directory doesn’t exists, it will create new files whether the “Override” field is “True” or “False”.
The source directory has two folders inside and each folder has two files.
After the process runs, you will see TestDirectory_Copy is created with two folders inside.
If we set the CopySubDirectory field to ‘False’, it only creates the directory itself, no folders and files will be created.
CopyDirectory If Target Directory Exists
In this example, we want to copy TestDirectory to TestDirectory_Copy. Both of them already exist.
If we set CopySubDirectory to ‘False’, the service returns ‘True’, which means it runs successfully. However, there is no change in TestDirectory_Copy.
If CopySubDirectory is ‘True’, sub directories under TestDirectory will be created under TestDirectory_Copy. Since both File111 and File222 do not exist in TestDirectory_Copy, they will be created whether the “Override” field is “True” or “False”.
If before we copy the directory, one of the sub directories is the same with source directory and we set CopySubDirectory and Override to “True”.
After we run the process, the file in target directory is overridden by the file in source directory.