$cs.File_DelTree
Description
Section titled “Description”Recursively deletes the directory at path and everything under it. If path doesn’t exist, the function returns silently with no error.
Syntax
Section titled “Syntax”$cs.File_DelTree(string path)
Parameters
Section titled “Parameters”path (String)
Section titled “path (String)”Full path of the directory to delete.
Return value
Section titled “Return value”None.
Example
Section titled “Example”$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:
$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:
$cs.File_DelTree("$env:ProgramData\Contoso\App")