Skip to content

Modern Fs CreateDirAll

Paul Squires edited this page Oct 19, 2026 · 6 revisions

Home › Filesystem › Filesystem Library › CreateDirAll

CreateDirAll

Creates a folder and any missing parents; succeeds if it already exists.

Syntax

CreateDirAll( p )
CreateDirAll( p, posixMode )    '' the mode of every directory it creates; ignored on Windows

Notes

  • mkdir -p; SUCCEEDS if it is already a directory

Examples

#import "std/fs"
using fs

'' Everything below happens inside a temp directory of its own, and is
'' removed at the end
dim td as FsResultUStr = CreateTempDir( "fbdoc" )
dim as ustring dir_ = td.Value( )

'' mkdir -p: creates every missing parent
dim as ustring deep = PathJoin( dir_, "a", "b", "c" )

print CreateDirAll( deep ).IsOk( )       '' true
print IsDir( deep )                      '' true

'' And it SUCCEEDS when the directory is already there, which is the
'' difference from CreateDir -- so it is the one to call when you want
'' the directory to exist rather than to have made it
print CreateDirAll( deep ).IsOk( )       '' true

RemoveDirAll( dir_ )

Library: Filesystem Library
Category: Filesystem
Documented under: File Operations

Clone this wiki locally