DirExist function

Purpose

Checks if the specified directory exists.

Syntax

f? = DirExist( Path$ [, fCreate?])

f, fCreate: boolean expression
Path$: string expression

Description

DirExist verifies that the directory in Path$ exists. It returns True if the path is a valid directory, or False otherwise. When the directory doesn't exist and the optional parameter fCreate is True the directory is created. When the creation fails, the return value is False.

Example

$Library "gfawinx"

Debug.Show

Trace DirExist("C:\")

Trace DirExist("C:\tmp")

Trace DirExist("\\surface4\develop")

Trace DirExist("C:\tmp\ok3", True)

Remarks

DirExist uses PathIsDirectory() API from shlwapi.dll, which does a better job than GetAttr, it can check for directories that GetAttr doesn't detect.

See Also

GetAttr, Exist

{Created by Sjouke Hamstra; Last updated: 24/08/2021 by James Gaite}