$cs.File_CreateDirectory
Description
Section titled “Description”Creates the directory at path, including any missing parent directories, if it doesn’t already exist. If it already exists, nothing happens — no error is raised.
Syntax
Section titled “Syntax”$cs.File_CreateDirectory(string path)
Parameters
Section titled “Parameters”path (String)
Section titled “path (String)”Full path of the directory to create.
Return value
Section titled “Return value”None.
Example
Section titled “Example”$cs.File_CreateDirectory("${env:ProgramFiles(x86)}\WinSCP")Create a nested log folder before writing to it, since File_CreateDirectory also creates any missing parent folders in one call:
$LogFolder = "$env:ProgramData\Contoso\App\Logs\2026"$cs.File_CreateDirectory($LogFolder)$cs.File_AppendToFile((Join-Path $LogFolder "install.log"), "Install started")Because it’s a no-op when the folder already exists, it’s safe to call unconditionally at the start of Install to guarantee a data folder is present:
$DataFolder = Join-Path $env:ProgramData "Contoso\App\Data"$cs.File_CreateDirectory($DataFolder)