# $cs.File_DelEmptyFolder

> Deletes the folder at path, but only if it is completely empty.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-file-delemptyfolder/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Deletes the folder at `path`, but only if it is completely empty. "Empty" is determined by summing the size of every file anywhere under the folder, recursively — so a folder that only contains empty subfolders is still deleted. If `path` doesn't exist, or if it isn't empty, the function does nothing and does not raise an error.

### Syntax

$cs.File_DelEmptyFolder(string path)

### Parameters

#### path (String)

Folder to delete if it is empty.

### Return value

None.

### Example

**PowerShell**

```powershell
$cs.File_DelEmptyFolder("$env:ProgramData\Notepad++")
```

In `PostUninstall`, after removing the application's files, use it to tidy up the install folder only if nothing else was left behind in it:

```powershell
$InstallFolder = "C:\Program Files\Contoso\App"
$cs.File_DelFile((Join-Path $InstallFolder "app.exe"))
$cs.File_DelEmptyFolder($InstallFolder)
```

It's also safe to call on a folder that only contains empty subfolders, since emptiness is checked recursively by total file size:

```powershell
$cs.File_DelEmptyFolder("$env:ProgramData\Contoso\App\Cache")
```

### Related functions

[$cs.File_DelTree](/capainstaller/powerpacks/cs-file-deltree/) [$cs.File_ExistDir](/capainstaller/powerpacks/cs-file-existdir/)
