Skip to content

$cs.File_DelTree

Recursively deletes the directory at path and everything under it. If path doesn’t exist, the function returns silently with no error.

$cs.File_DelTree(string path)

Full path of the directory to delete.

None.

Terminal window
$cs.File_DelTree("$env:ProgramData\Notepad++")

Remove an old version’s install folder before laying down a new one, so a version upgrade doesn’t leave stale files behind:

Terminal window
$cs.File_DelTree("C:\Program Files\Contoso\App-2.0")
$Source = Join-Path $global:Packageroot "kit"
$cs.File_CopyTree($Source, "C:\Program Files\Contoso\App-3.0")

In Uninstall, remove the application’s entire data folder in one call, including all subfolders and files:

Terminal window
$cs.File_DelTree("$env:ProgramData\Contoso\App")

$cs.File_DelFile $cs.File_DelEmptyFolder $cs.File_ExistDir