Skip to content

$cs.File_CopyTree

Recursively copies a directory tree from source to destination, creating destination if it doesn’t exist.

$cs.File_CopyTree(string source, string destination, bool copySubDirs = true, bool overwrite = true)

Source folder to copy. Throws an error if it does not exist.

Destination folder to copy to. Created automatically if it doesn’t exist.

Also copy subfolders. Default is $true (full recursive copy).

Overwrite existing files at the destination. Default is $true. If set to $false, any file that already exists at the destination is silently skipped and the rest of the copy still proceeds.

None.

Terminal window
$Source = Join-Path $global:Packageroot "Dummy"
$cs.File_CopyTree($Source, "C:\Program Files\CapaInstaller\Dummy")

Deploy a full configuration folder from the kit to the target machine, without overwriting any files an administrator may already have customized:

Terminal window
$Source = Join-Path $global:Packageroot "kit\config"
$cs.File_CopyTree($Source, "C:\ProgramData\Contoso\App\config", $true, $false)

Copy only the top-level files from a folder, leaving any subfolders behind, by setting copySubDirs=$false:

Terminal window
$Source = Join-Path $global:Packageroot "kit\templates"
$cs.File_CopyTree($Source, "C:\ProgramData\Contoso\App\templates", $false)

$cs.File_CopyFile $cs.File_DelTree $cs.File_ExistDir